]>
Commit | Line | Data |
---|---|---|
1 | /* | |
2 | * Copyright (C) 1996-2021 The Squid Software Foundation and contributors | |
3 | * | |
4 | * Squid software is distributed under GPLv2+ license and includes | |
5 | * contributions from numerous individuals and organizations. | |
6 | * Please see the COPYING and CONTRIBUTORS files for details. | |
7 | */ | |
8 | ||
9 | #include "squid.h" | |
10 | #include "acl/FilledChecklist.h" | |
11 | #include "acl/HttpHeaderData.h" | |
12 | #include "acl/Note.h" | |
13 | #include "acl/NoteData.h" | |
14 | #include "HttpRequest.h" | |
15 | ||
16 | /* Acl::AnnotationStrategy */ | |
17 | ||
18 | const Acl::Options & | |
19 | Acl::AnnotationStrategy::options() | |
20 | { | |
21 | static const Acl::CharacterSetOption Delimiters; | |
22 | static const Acl::Options MyOptions = { | |
23 | { "-m", &Delimiters } | |
24 | }; | |
25 | Delimiters.linkWith(&delimiters); | |
26 | return MyOptions; | |
27 | } | |
28 | ||
29 | /* ACLNoteStrategy */ | |
30 | ||
31 | int | |
32 | ACLNoteStrategy::match(ACLData<MatchType> * &data, ACLFilledChecklist *checklist) | |
33 | { | |
34 | if (const auto request = checklist->request) { | |
35 | if (request->hasNotes() && matchNotes(data, request->notes().getRaw())) | |
36 | return 1; | |
37 | #if USE_ADAPTATION | |
38 | const Adaptation::History::Pointer ah = request->adaptLogHistory(); | |
39 | if (ah != NULL && ah->metaHeaders != NULL && matchNotes(data, ah->metaHeaders.getRaw())) | |
40 | return 1; | |
41 | #endif | |
42 | } | |
43 | return 0; | |
44 | } | |
45 | ||
46 | bool | |
47 | ACLNoteStrategy::matchNotes(ACLData<MatchType> *noteData, const NotePairs *note) const | |
48 | { | |
49 | const NotePairs::Entries &entries = note->expandListEntries(&delimiters.value); | |
50 | for (auto e: entries) | |
51 | if (noteData->match(e.getRaw())) | |
52 | return true; | |
53 | return false; | |
54 | } | |
55 |