]>
Commit | Line | Data |
---|---|---|
bbc27441 | 1 | /* |
4ac4a490 | 2 | * Copyright (C) 1996-2017 The Squid Software Foundation and contributors |
bbc27441 AJ |
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 | ||
39baccc8 | 9 | #include "squid.h" |
4eac3407 | 10 | #include "acl/FilledChecklist.h" |
602d9612 A |
11 | #include "acl/HttpHeaderData.h" |
12 | #include "acl/Note.h" | |
76ee67ac | 13 | #include "acl/NoteData.h" |
39baccc8 | 14 | #include "HttpRequest.h" |
4eac3407 CT |
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 */ | |
39baccc8 CT |
30 | |
31 | int | |
4eac3407 | 32 | ACLNoteStrategy::match(ACLData<MatchType> * &data, ACLFilledChecklist *checklist) |
39baccc8 | 33 | { |
76ee67ac | 34 | if (const auto request = checklist->request) { |
4eac3407 | 35 | if (request->hasNotes() && matchNotes(data, request->notes().getRaw())) |
76ee67ac CT |
36 | return 1; |
37 | #if USE_ADAPTATION | |
38 | const Adaptation::History::Pointer ah = request->adaptLogHistory(); | |
4eac3407 | 39 | if (ah != NULL && ah->metaHeaders != NULL && matchNotes(data, ah->metaHeaders.getRaw())) |
76ee67ac CT |
40 | return 1; |
41 | #endif | |
42 | } | |
39baccc8 CT |
43 | return 0; |
44 | } | |
45 | ||
76ee67ac | 46 | bool |
4eac3407 | 47 | ACLNoteStrategy::matchNotes(ACLData<MatchType> *noteData, const NotePairs *note) const |
76ee67ac | 48 | { |
4eac3407 | 49 | const NotePairs::Entries &entries = note->expandListEntries(&delimiters.value); |
75d47340 CT |
50 | for (auto e: entries) |
51 | if (noteData->match(e.getRaw())) | |
76ee67ac | 52 | return true; |
76ee67ac CT |
53 | return false; |
54 | } | |
55 |