]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
more predefined charactersets
authorFrancesco Chemolli <kinkie@squid-cache.org>
Mon, 30 Dec 2013 09:44:52 +0000 (10:44 +0100)
committerFrancesco Chemolli <kinkie@squid-cache.org>
Mon, 30 Dec 2013 09:44:52 +0000 (10:44 +0100)
src/base/CharacterSet.cc
src/base/CharacterSet.h
src/base/testCharacterSet.cc
src/base/testCharacterSet.h

index 31a45fb0367f2ca01617fe6640173dfeea3b3cc1..8eee3e7317a60673710071634b26b705f0535351 100644 (file)
@@ -61,11 +61,20 @@ CharacterSet::CharacterSet(const char *label, const RangeSpec & ranges)
 }
 
 const CharacterSet
-CharacterSet::ALPHA("ALPHA", {{ 'a', 'z' }, { 'A', 'Z'} }),
+CharacterSet::ALPHA("ALPHA", {{ 'a', 'z' }, { 'A', 'Z'}}),
 CharacterSet::BIT("BIT","01"),
 CharacterSet::CHAR("CHAR",{{ 1, 127}}),
+CharacterSet::CR("CR","\r"),
 CharacterSet::CRLF("CRLF","\r\n"),
 CharacterSet::DIGIT("DIGIT","0123456789"),
+CharacterSet::DQUOTE("DQUOTE","\""),
+CharacterSet::HTAB("HTAB","\t"),
 CharacterSet::HEXDIG("HEXDIG","0123456789aAbBcCdDeEfF"),
-CharacterSet::WSP("WSP"," \t")
+CharacterSet::SP("SP"," "),
+CharacterSet::VCHAR("VCHAR",{{ 0x21, 0x7e }} ),
+CharacterSet::WSP("WSP"," \t"),
+CharacterSet::TCHAR("TCHAR","!#$%&'*+-.^_`|~0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"),
+CharacterSet::SPECIAL("SPECIAL","()<>@,;:\\\"/[]?={}")
+//,CharacterSet::QDTEXT("QDTEXT",{{9,9},{0x20,0x21},{0x23,0x5b},{0x5d,0x7e},{0x80,0xff}})
+//,CharacterSet::OBSTEXT("OBSTEXT",{{0x80,0xff}})
 ;
index 003ea88eb8d2e39017ca583ad0ae148f77c0f799..569ea845272f71ca6115acb629ae4a145069630c 100644 (file)
@@ -41,20 +41,40 @@ public:
     /// optional set label for debugging (default: "anonymous")
     const char * name;
 
+    // common character sets, insipired to RFC5234
     // A-Za-z
     static const CharacterSet ALPHA;
     // 0-1
     static const CharacterSet BIT;
     // any 7-bit US-ASCII character, except for NUL
     static const CharacterSet CHAR;
+    // carriage return
+    static const CharacterSet CR;
     // CRLF
     static const CharacterSet CRLF;
+    // double quote
+    static const CharacterSet DQUOTE;
     // 0-9
     static const CharacterSet DIGIT;
     // 0-9aAbBcCdDeEfF
     static const CharacterSet HEXDIG;
+    // horizontal tab
+    static const CharacterSet HTAB;
+    // white space
+    static const CharacterSet SP;
+    // visible (printable) characters
+    static const CharacterSet VCHAR;
     // <space><tab>
     static const CharacterSet WSP;
+    // character sets from draft httpbis
+    // any VCHAR except for SPECIAL
+    static const CharacterSet TCHAR;
+    // special VCHARs
+    static const CharacterSet SPECIAL;
+    // qdtext (ready but not enabled for now)
+    //static const CharacterSet QDTEXT;
+    // obs-text
+    //static const CharacterSet OBSTEXT;
 
 private:
     /** index of characters in this set
index 702d26317d8cd5f75dfa69f42442036ee7588463..73df3d774af2c551560cb57ab6d5a66f6509eb0c 100644 (file)
@@ -62,3 +62,21 @@ testCharacterSet::CharacterSetConstants()
     CPPUNIT_ASSERT_EQUAL(true,CharacterSet::ALPHA['Z']);
     CPPUNIT_ASSERT_EQUAL(false,CharacterSet::ALPHA['5']);
 }
+
+void
+testCharacterSet::CharacterSetUnion()
+{
+    {
+        CharacterSet hex("hex","");
+        hex += CharacterSet::DIGIT;
+        hex += CharacterSet(NULL,"aAbBcCdDeEfF");
+        for (int j = 0; j < 255; ++j)
+            CPPUNIT_ASSERT_EQUAL(CharacterSet::HEXDIG[j],hex[j]);
+    }
+    {
+        CharacterSet hex(NULL,"");
+        hex = CharacterSet::DIGIT + CharacterSet(NULL,"aAbBcCdDeEfF");
+        for (int j = 0; j < 255; ++j)
+            CPPUNIT_ASSERT_EQUAL(CharacterSet::HEXDIG[j],hex[j]);
+    }
+}
index dd4319e3ae450ee44819a94e8b0d6bbd32c859ef..83a281758aa6489d91e8370a3bec4eb04ed2f9ae 100644 (file)
@@ -12,6 +12,7 @@ class testCharacterSet : public CPPUNIT_NS::TestFixture
     CPPUNIT_TEST( CharacterSetAdd );
     CPPUNIT_TEST( CharacterSetAddRange );
     CPPUNIT_TEST( CharacterSetConstants );
+    CPPUNIT_TEST( CharacterSetUnion );
     CPPUNIT_TEST_SUITE_END();
 
 protected:
@@ -19,6 +20,7 @@ protected:
     void CharacterSetAdd();
     void CharacterSetAddRange();
     void CharacterSetConstants();
+    void CharacterSetUnion();
 };
 
 #endif /* SQUID_BASE_TESTCHARACTERSET_H */