]>
Commit | Line | Data |
---|---|---|
bbc27441 | 1 | /* |
b8ae064d | 2 | * Copyright (C) 1996-2023 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 | { | |
8d76389c EB |
21 | static const Acl::CharacterSetOption Delimiters("-m"); |
22 | static const Acl::Options MyOptions = { &Delimiters }; | |
4eac3407 CT |
23 | Delimiters.linkWith(&delimiters); |
24 | return MyOptions; | |
25 | } | |
26 | ||
27 | /* ACLNoteStrategy */ | |
39baccc8 CT |
28 | |
29 | int | |
4eac3407 | 30 | ACLNoteStrategy::match(ACLData<MatchType> * &data, ACLFilledChecklist *checklist) |
39baccc8 | 31 | { |
76ee67ac | 32 | if (const auto request = checklist->request) { |
4eac3407 | 33 | if (request->hasNotes() && matchNotes(data, request->notes().getRaw())) |
76ee67ac CT |
34 | return 1; |
35 | #if USE_ADAPTATION | |
36 | const Adaptation::History::Pointer ah = request->adaptLogHistory(); | |
aee3523a | 37 | if (ah != nullptr && ah->metaHeaders != nullptr && matchNotes(data, ah->metaHeaders.getRaw())) |
76ee67ac CT |
38 | return 1; |
39 | #endif | |
40 | } | |
39baccc8 CT |
41 | return 0; |
42 | } | |
43 | ||
76ee67ac | 44 | bool |
4eac3407 | 45 | ACLNoteStrategy::matchNotes(ACLData<MatchType> *noteData, const NotePairs *note) const |
76ee67ac | 46 | { |
4eac3407 | 47 | const NotePairs::Entries &entries = note->expandListEntries(&delimiters.value); |
75d47340 CT |
48 | for (auto e: entries) |
49 | if (noteData->match(e.getRaw())) | |
76ee67ac | 50 | return true; |
76ee67ac CT |
51 | return false; |
52 | } | |
53 |