]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Polish rfc1738 library code. Add cppunit tests.
authorAmos Jeffries <squid3@treenet.co.nz>
Mon, 9 Nov 2009 11:25:11 +0000 (00:25 +1300)
committerAmos Jeffries <squid3@treenet.co.nz>
Mon, 9 Nov 2009 11:25:11 +0000 (00:25 +1300)
 * Adds API header file for this library.
 * Reveals the do_escape API and creates meaningful flags for its API.
 * Adds documentation.
 * Convert original unit tests by Robert Collins to cppunit code
 * Add new tests based on work for Samba by Andrew Bartlett

34 files changed:
helpers/basic_auth/LDAP/basic_ldap_auth.cc
helpers/basic_auth/MSNT/msntauth.c
helpers/basic_auth/NCSA/basic_ncsa_auth.cc
helpers/basic_auth/PAM/pam_auth.c
helpers/basic_auth/SASL/sasl_auth.c
helpers/basic_auth/YP/yp_auth.c
helpers/basic_auth/getpwnam/basic_getpwnam_auth.cc
helpers/external_acl/ip_user/main.c
helpers/external_acl/ldap_group/squid_ldap_group.c
helpers/external_acl/unix_group/check_group.c
include/rfc1738.h [new file with mode: 0644]
include/util.h
lib/Makefile.am
lib/rfc1738.c
lib/tests/testRFC1738.cc [new file with mode: 0644]
lib/tests/testRFC1738.h [new file with mode: 0644]
src/access_log.cc
src/acl/Url.cc
src/acl/UrlPath.cc
src/auth/basic/auth_basic.cc
src/cache_cf.cc
src/client_side.cc
src/errorpage.cc
src/external_acl.cc
src/ftp.cc
src/gopher.cc
src/http.cc
src/icp_v2.cc
src/ipc.cc
src/redirect.cc
src/url.cc
test-suite/Makefile.am
test-suite/rfc1738.cc [deleted file]
tools/cachemgr.cc

index eaee9ce809f3ccf1d5ba4b152ff8e49f5c0414cb..02b626c71ce43f80955415be17a53bf91b72c401 100644 (file)
@@ -84,6 +84,7 @@
 
 #define LDAP_DEPRECATED 1
 
+#include "rfc1738.h"
 #include "util.h"
 
 #include <stdio.h>
index a877089fe79d65995c6a5f6b371f9e6f22f913f4..ab9f04dc72b69a1933104ababa26973e8158382e 100644 (file)
@@ -31,6 +31,7 @@
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
 
+#include "rfc1738.h"
 #include "util.h"
 
 #include <stdio.h>
index a7f3de977a00487846fddb44d38a279a58bcdbe1..2f49f45ec7a8209c9c282ffe16ae893b721f34bc 100644 (file)
@@ -18,6 +18,7 @@
  */
 
 #include "config.h"
+#include "rfc1738.h"
 
 #if HAVE_STDIO_H
 #include <stdio.h>
index 90174b8942f8aa049439cf060efa6c955ff4bf4b..a80ac1d5138fd4b277a7acd8e1491972a7588685 100644 (file)
@@ -63,6 +63,7 @@
  * Compile this program with: gcc -o pam_auth pam_auth.c -lpam -ldl
  */
 
+#include "rfc1738.h"
 #include "util.h"
 
 #include <stdio.h>
index f1ff3c4e394ba47ca173572c95d9b5186863a208..6efa30dfeaf0bd6522099f69fe43f6855247cbcd 100644 (file)
@@ -31,6 +31,7 @@
 #include <stdlib.h>
 #include <string.h>
 
+#include "rfc1738.h"
 #include "util.h"
 
 #ifdef HAVE_SASL_SASL_H
index 4f6d23634fffcb09d8fd62dfc9b4383c0c2f00d3..379adabe04129caf7a3800f7b0b4d16c4325f134 100644 (file)
@@ -4,6 +4,8 @@
  */
 
 #include "config.h"
+#include "rfc1738.h"
+
 #if HAVE_STDIO_H
 #include <stdio.h>
 #endif
index b119ebf67ecb1cb6f8e56751bff69c6c9a1ed747..a75b8b4f07bd99ff3365075d10c74798ee170be1 100644 (file)
@@ -25,6 +25,7 @@
  */
 
 #include "config.h"
+#include "rfc1738.h"
 
 #if HAVE_STDIO_H
 #include <stdio.h>
index 5b03b56595f0a7fe905fd2316c52f3477e370f01..f9537572ef1b8898d9f2b52596e6b61d25ee37a6 100644 (file)
@@ -19,6 +19,7 @@
 *
 */
 
+#include "rfc1738.h"
 #include "util.h"
 
 #include <stdio.h>
index afdb8d491a3b5d6a9c6df479013dfd768eca4bcc..a89c3f43aafde7e1e073f5977064c77fa1b80a7c 100644 (file)
@@ -35,6 +35,7 @@
 
 #define LDAP_DEPRECATED 1
 
+#include "rfc1738.h"
 #include "util.h"
 
 #include <stdio.h>
index eb277ad4e0c277110b5e7e065905915f2fa5be15..f7d1c4bd36e0afef5527501bab2db06a519814c7 100644 (file)
@@ -52,6 +52,7 @@
  *
  */
 
+#include "rfc1738.h"
 #include "util.h"
 
 #include <stdio.h>
diff --git a/include/rfc1738.h b/include/rfc1738.h
new file mode 100644 (file)
index 0000000..b3538ec
--- /dev/null
@@ -0,0 +1,45 @@
+#ifndef _SQUID_INCLUDE_RFC1738_H
+#define _SQUID_INCLUDE_RFC1738_H
+
+/* for SQUIDCEXTERN */
+#include "config.h"
+
+
+/* Encoder rfc1738_do_escape flag values. */
+#define RFC1738_ESCAPE_UNSAFE     0
+#define RFC1738_ESCAPE_RESERVED   1
+#define RFC1738_ESCAPE_UNESCAPED -1
+
+
+/**
+ * \group rfc1738 RFC 1738 URL-escaping library
+ *
+ * Public API is formed of a triplet of encode functions mapping to the rfc1738_do_encode() engine.
+ *
+ * ASCII characters are split into three groups:
+ * \item SAFE     Characters which are safe to occur in any URL. For example A,B,C
+ * \item UNSAFE   Characters which are completely usafe to occur in any URL. For example; backspace, tab, space, newline
+ * \item RESERVED Characters which are reserved for special meaning and may only occur in certain parts of a URL.
+ *
+ * Returns a static buffer containing the RFC 1738 compliant, escaped version of the given url.
+ *
+ * \param flags  RFC1738_ESCAPE_UNSAFE    Only encode unsafe characters. Ignore reserved.
+ * \param flags  RFC1738_ESCAPE_RESERVED  Encode all unsafe and reserved characters.
+ * \param flags  RFC1738_ESCAPE_UNESCAPED Encode all unsafe characters which have not already been encoded.
+ */
+SQUIDCEXTERN char *rfc1738_do_escape(const char *url, int flags);
+
+/* Old API functions */
+#define rfc1738_escape(x)  rfc1738_do_escape(x, RFC1738_ESCAPE_UNSAFE)
+#define rfc1738_escape_part(x)  rfc1738_do_escape(x, RFC1738_ESCAPE_RESERVED)
+#define rfc1738_escape_unescaped(x)  rfc1738_do_escape(x, RFC1738_ESCAPE_UNESCAPED)
+
+
+/**
+ * Unescape a URL string according to RFC 1738 specification.
+ * String is unescaped in-place
+ */
+SQUIDCEXTERN void rfc1738_unescape(char *url);
+
+
+#endif /* _SQUID_INCLUDE_RFC1738_H */
index 28f56d29bfef02b19e074a3a837317a8cb953248..0bf570b4c272bc99b2a012f74441aeb1f315c56e 100644 (file)
@@ -90,12 +90,6 @@ SQUIDCEXTERN void xxfree(const void *);
 #include "SquidNew.h"
 #endif
 
-/* rfc1738.c */
-SQUIDCEXTERN char *rfc1738_escape(const char *);
-SQUIDCEXTERN char *rfc1738_escape_unescaped(const char *);
-SQUIDCEXTERN char *rfc1738_escape_part(const char *);
-SQUIDCEXTERN void rfc1738_unescape(char *);
-
 /* charset.c */
 SQUIDCEXTERN char *latin1_to_utf8(char *out, size_t size, const char *in);
 
index 02bee1739acaf08de0ada3ec6aeccf52d381b4d0..444b10dd35bb8f42f85b265cd1723d005d9078d2 100644 (file)
@@ -99,6 +99,8 @@ tests_testAll_SOURCES= \
        tests/testArray.cc \
        tests/testRFC1035.h \
        tests/testRFC1035.cc \
+       tests/testRFC1738.h \
+       tests/testRFC1738.cc \
        tests/testMain.cc \
        $(XPROF_STATS_SOURCE) \
        $(WIN32SRC) \
index bba0a5d6a7d9046d724f354089e0e307d3c10cd3..a0edaf75761553e0287f17e60577d87bb9ee0038 100644 (file)
@@ -33,6 +33,8 @@
  */
 
 #include "config.h"
+#include "rfc1738.h"
+#include "util.h"
 
 #if HAVE_STDIO_H
 #include <stdio.h>
@@ -41,8 +43,6 @@
 #include <string.h>
 #endif
 
-#include "util.h"
-
 /*
  *  RFC 1738 defines that these characters should be escaped, as well
  *  any non-US-ASCII character or anything between 0x00 - 0x1F.
@@ -82,8 +82,8 @@ static char rfc1738_reserved_chars[] = {
  *  rfc1738_escape - Returns a static buffer contains the RFC 1738
  *  compliant, escaped version of the given url.
  */
-static char *
-rfc1738_do_escape(const char *url, int encode_reserved)
+char *
+rfc1738_do_escape(const char *url, int flags)
 {
     static char *buf;
     static size_t bufsize = 0;
@@ -94,7 +94,7 @@ rfc1738_do_escape(const char *url, int encode_reserved)
     if (buf == NULL || strlen(url) * 3 > bufsize) {
         xfree(buf);
         bufsize = strlen(url) * 3 + 1;
-        buf = xcalloc(bufsize, 1);
+        buf = (char*)xcalloc(bufsize, 1);
     }
     for (p = url, q = buf; *p != '\0' && q < (buf + bufsize - 1); p++, q++) {
         do_escape = 0;
@@ -107,10 +107,10 @@ rfc1738_do_escape(const char *url, int encode_reserved)
             }
         }
         /* Handle % separately */
-        if (encode_reserved >= 0 && *p == '%')
+        if (flags != RFC1738_ESCAPE_UNESCAPED && *p == '%')
             do_escape = 1;
         /* RFC 1738 defines these chars as reserved */
-        for (i = 0; i < sizeof(rfc1738_reserved_chars) && encode_reserved > 0; i++) {
+        for (i = 0; i < sizeof(rfc1738_reserved_chars) && flags == RFC1738_ESCAPE_RESERVED; i++) {
             if (*p == rfc1738_reserved_chars[i]) {
                 do_escape = 1;
                 break;
@@ -143,6 +143,7 @@ rfc1738_do_escape(const char *url, int encode_reserved)
     return (buf);
 }
 
+#if 0 /* legacy API */
 /*
  * rfc1738_escape - Returns a static buffer that contains the RFC
  * 1738 compliant, escaped version of the given url.
@@ -172,6 +173,7 @@ rfc1738_escape_part(const char *url)
 {
     return rfc1738_do_escape(url, 1);
 }
+#endif /* 0 */
 
 /*
  *  rfc1738_unescape() - Converts escaped characters (%xy numbers) in
diff --git a/lib/tests/testRFC1738.cc b/lib/tests/testRFC1738.cc
new file mode 100644 (file)
index 0000000..5ee0d5e
--- /dev/null
@@ -0,0 +1,155 @@
+#include "config.h"
+
+#if HAVE_ASSERT_H
+#include <assert.h>
+#endif
+
+#include "testRFC1738.h"
+
+/* Being a C library code it is best bodily included and tested with C++ type-safe techniques. */
+#include "lib/rfc1738.c"
+
+CPPUNIT_TEST_SUITE_REGISTRATION( testRFC1738 );
+
+/* Regular Format de-coding tests */
+void testRFC1738::testUrlDecode()
+{
+    char *unescaped_str;
+
+    /* regular URL-path */
+    unescaped_str = xstrdup("%2Fdata%2Fsource%2Fpath");
+    rfc1738_unescape(unescaped_str);
+    CPPUNIT_ASSERT(memcmp(unescaped_str, "/data/source/path",18)==0);
+    xfree(unescaped_str);
+
+    /* path in full URL */
+    unescaped_str = xstrdup("http://foo.invalid%2Fdata%2Fsource%2Fpath");
+    rfc1738_unescape(unescaped_str);
+    CPPUNIT_ASSERT(memcmp(unescaped_str, "http://foo.invalid/data/source/path",36)==0);
+    xfree(unescaped_str);
+
+// TODO query string...
+
+    /* Newline %0A encoded */
+    unescaped_str = xstrdup("w%0Ard");
+    rfc1738_unescape(unescaped_str);
+    CPPUNIT_ASSERT(memcmp(unescaped_str, "w\nrd",5)==0);
+    xfree(unescaped_str);
+
+    /* Handle Un-encoded % */
+    unescaped_str = xstrdup("w%rd");
+    rfc1738_unescape(unescaped_str);
+    CPPUNIT_ASSERT(memcmp(unescaped_str, "w%rd",5)==0);
+    xfree(unescaped_str);
+
+    /* Handle encoded % */
+    unescaped_str = xstrdup("w%%rd");
+    rfc1738_unescape(unescaped_str);
+    CPPUNIT_ASSERT(memcmp(unescaped_str, "w%%rd",6)==0);
+    xfree(unescaped_str);
+
+    /* Handle mixed-encoded % */
+    unescaped_str = xstrdup("w%%%rd");
+    rfc1738_unescape(unescaped_str);
+    CPPUNIT_ASSERT(memcmp(unescaped_str, "w%%rd",6)==0);
+    xfree(unescaped_str);
+
+    /* A corrupt string */
+    unescaped_str = xstrdup("Bad String %1");
+    rfc1738_unescape(unescaped_str);
+    CPPUNIT_ASSERT(memcmp(unescaped_str, "Bad String %1",14)==0);
+    xfree(unescaped_str);
+
+
+    /* A partly corrupt string */
+    unescaped_str = xstrdup("Bad String %1A%3");
+    rfc1738_unescape(unescaped_str);
+    CPPUNIT_ASSERT(memcmp(unescaped_str, "Bad String \032%3",15)==0);
+    xfree(unescaped_str);
+
+    /* A non corrupt string */
+    unescaped_str = xstrdup("Good String %1A");
+    rfc1738_unescape(unescaped_str);
+    CPPUNIT_ASSERT(memcmp(unescaped_str, "Good String \032",14)==0);
+    xfree(unescaped_str);
+}
+
+/**
+ * Public API is formed of a triplet of encode functions mapping to the rfc1738_do_encode() engine.
+ *
+ * Flags:
+ * rfc1738_escape == 0
+ * rfc1738_escape_unescaped == -1
+ * rfc1738_escape_part == 1
+ */
+void testRFC1738::testUrlEncode()
+{
+    char *result;
+
+#define RFC1738_ESCAPE_UNSAFE     0
+#define RFC1738_ESCAPE_RESERVED   1
+#define RFC1738_ESCAPE_UNESCAPED -1
+
+    /* TEST: Escaping only unsafe characters */
+
+    /* regular URL (no encoding needed) */
+    result = rfc1738_do_escape("http://foo.invalid/data/source/path", RFC1738_ESCAPE_UNSAFE);
+    CPPUNIT_ASSERT(memcmp(result, "http://foo.invalid/data/source/path",36)==0);
+
+    /* long string of unsafe # characters */
+    result = rfc1738_do_escape("################ ################ ################ ################ ################ ################ ################ ################", RFC1738_ESCAPE_UNSAFE);
+    CPPUNIT_ASSERT(memcmp(result, "%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%20%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%20%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%20%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%20%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%20%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%20%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%20%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23",406)==0);
+
+
+    /* TEST: escaping only reserved characters */
+
+    /* regular URL (full encoding requested) */
+    result = rfc1738_do_escape("http://foo.invalid/data/source/path", RFC1738_ESCAPE_RESERVED);
+    CPPUNIT_ASSERT(memcmp(result, "http%3A%2F%2Ffoo.invalid%2Fdata%2Fsource%2Fpath",48)==0);
+
+    /* regular path (encoding wanted for ALL special chars) */
+    result = rfc1738_do_escape("/data/source/path", RFC1738_ESCAPE_RESERVED);
+    CPPUNIT_ASSERT(memcmp(result, "%2Fdata%2Fsource%2Fpath",24)==0);
+
+
+    /* TEST: safety-escaping a string already partially escaped */
+
+    /* escaping of dangerous characters in a partially escaped string */
+    result = rfc1738_do_escape("http://foo.invalid/data%2Fsource[]", RFC1738_ESCAPE_UNESCAPED);
+    CPPUNIT_ASSERT(memcmp(result, "http://foo.invalid/data%2Fsource%5B%5D",39)==0);
+
+    /* escaping of hexadecimal 0xFF characters in a partially escaped string */
+    result = rfc1738_do_escape("http://foo.invalid/data%2Fsource\xFF\xFF", RFC1738_ESCAPE_UNESCAPED);
+    CPPUNIT_ASSERT(memcmp(result, "http://foo.invalid/data%2Fsource%FF%FF",39)==0);
+
+}
+
+/** SECURITY BUG TESTS: avoid null truncation attacks by skipping %00 bytes */
+void testRFC1738::PercentZeroNullDecoding()
+{
+    char *unescaped_str;
+
+    /* Attack with %00 encoded NULL */
+    unescaped_str = xstrdup("w%00rd");
+    rfc1738_unescape(unescaped_str);
+    CPPUNIT_ASSERT(memcmp(unescaped_str, "w%00rd",7)==0);
+    xfree(unescaped_str);
+
+    /* Attack with %0 encoded NULL */
+    unescaped_str = xstrdup("w%0rd");
+    rfc1738_unescape(unescaped_str);
+    CPPUNIT_ASSERT(memcmp(unescaped_str, "w%0rd",6)==0);
+    xfree(unescaped_str);
+
+    /* Handle '0' bytes embeded in encoded % */
+    unescaped_str = xstrdup("w%%00%rd");
+    rfc1738_unescape(unescaped_str);
+    CPPUNIT_ASSERT(memcmp(unescaped_str, "w%00%rd",8)==0);
+    xfree(unescaped_str);
+
+    /* Handle NULL bytes with encoded % */
+    unescaped_str = xstrdup("w%%%00%rd");
+    rfc1738_unescape(unescaped_str);
+    CPPUNIT_ASSERT(memcmp(unescaped_str, "w%%00%rd",9)==0);
+    xfree(unescaped_str);
+}
diff --git a/lib/tests/testRFC1738.h b/lib/tests/testRFC1738.h
new file mode 100644 (file)
index 0000000..624f720
--- /dev/null
@@ -0,0 +1,28 @@
+#ifndef SQUID_LIB_TEST_RFC1738_H
+#define SQUID_LIB_TEST_RFC1738_H
+
+#include <cppunit/extensions/HelperMacros.h>
+
+/**
+ * Test the URL coder RFC 1738 Engine
+ */
+class testRFC1738 : public CPPUNIT_NS::TestFixture
+{
+    CPPUNIT_TEST_SUITE( testRFC1738 );
+//    CPPUNIT_TEST( testUrlDecode );
+//    CPPUNIT_TEST( testUrlEncode );
+
+    CPPUNIT_TEST( PercentZeroNullDecoding );
+    CPPUNIT_TEST_SUITE_END();
+
+public:
+
+protected:
+    void testUrlDecode();
+    void testUrlEncode();
+
+    // bugs.
+    void PercentZeroNullDecoding();
+};
+
+#endif /* SQUID_LIB_TEST_RFC1738_H */
index a69fa2984b5c14dd68d178a90f629b2546c1e3ee..d08280e75a10d49d4dd30493cd9e14f1afbc13b5 100644 (file)
@@ -49,6 +49,7 @@
 #include "HttpReply.h"
 #include "HttpRequest.h"
 #include "MemBuf.h"
+#include "rfc1738.h"
 #include "SquidTime.h"
 
 static void accessLogSquid(AccessLogEntry * al, Logfile * logfile);
index bd26c081138874c08042fc18131f90a4882ca9ea..a7366b6a5512204e80e72c6d6138c5d911d73d0f 100644 (file)
@@ -38,7 +38,7 @@
 #include "acl/Url.h"
 #include "acl/Checklist.h"
 #include "acl/RegexData.h"
-
+#include "rfc1738.h"
 
 int
 ACLUrlStrategy::match (ACLData<char const *> * &data, ACLFilledChecklist *checklist)
index c36d170c86044d62f6de94446741873841655a7e..cd1a8bae52ee9077df375b1ed039ab0584aa06e0 100644 (file)
@@ -39,7 +39,7 @@
 #include "acl/Checklist.h"
 #include "acl/RegexData.h"
 #include "HttpRequest.h"
-
+#include "rfc1738.h"
 
 int
 ACLUrlPathStrategy::match (ACLData<char const *> * &data, ACLFilledChecklist *checklist)
index 9aa07bb53a7126a8902e400123bdb88e8f50c6b6..aae8d6a2b69276cf8a52fb52ebed07178ffaadb7 100644 (file)
@@ -44,6 +44,7 @@
 #include "Store.h"
 #include "HttpReply.h"
 #include "basicScheme.h"
+#include "rfc1738.h"
 #include "wordlist.h"
 #include "SquidTime.h"
 
index daec10505c52f70e9222934c61dea377b599a33b..b943ba14cb5161e4cc1f44cdeb97e6b42e950c39 100644 (file)
@@ -46,6 +46,7 @@
 #include "acl/Gadgets.h"
 #include "StoreFileSystem.h"
 #include "Parsing.h"
+#include "rfc1738.h"
 #include "MemBuf.h"
 #include "wordlist.h"
 #include "ident/Config.h"
index d1fa9d50a5ae7e12fa2920bf0f7d24033b90ff2d..f0de89502d520a7509e5adf9d62df2063080e99a 100644 (file)
 #include "SquidTime.h"
 #include "ChunkedCodingParser.h"
 #include "eui/Config.h"
+#include "rfc1738.h"
 
 #if LINGERING_CLOSE
 #define comm_close comm_lingering_close
index 1754494647b60bd5db4eda7649e944e844a70745..5a70d686e06fae590dccb69880fe4b17e5032da6 100644 (file)
@@ -43,6 +43,7 @@
 #include "MemObject.h"
 #include "fde.h"
 #include "MemBuf.h"
+#include "rfc1738.h"
 #include "URLScheme.h"
 #include "wordlist.h"
 
index 3c4f737084e1039befd6cbd4ac2a73592a650c55..90ff036841da45e62bf74a551191eb24aec06d76 100644 (file)
@@ -60,6 +60,7 @@
 #include "auth/Gadgets.h"
 #include "helper.h"
 #include "MemBuf.h"
+#include "rfc1738.h"
 #include "URLScheme.h"
 #include "wordlist.h"
 
index 5cc847a158b3daecc691d83544e57fdf83f79764..c8a48e4ca903f70907d53dd620bd5aad8c96d18a 100644 (file)
@@ -54,6 +54,7 @@
 #include "SquidTime.h"
 #include "URLScheme.h"
 #include "SquidString.h"
+#include "rfc1738.h"
 
 /**
  \defgroup ServerProtocolFTPInternal Server-Side FTP Internals
index 532151917ab7347213c35b034e1e7677378f0a52..4003b705436119ddcb71bfbb2f72f9e9bd635136 100644 (file)
@@ -45,6 +45,7 @@
 #endif
 #include "MemBuf.h"
 #include "forward.h"
+#include "rfc1738.h"
 #include "SquidTime.h"
 
 /**
index c45c6a156679db7e3134209e52f3a0dc4346ce54..749a070424fac73d303a2d8eedb68a95369ecc7a 100644 (file)
@@ -56,6 +56,7 @@
 #include "MemBuf.h"
 #include "MemObject.h"
 #include "protos.h"
+#include "rfc1738.h"
 #include "SquidTime.h"
 #include "Store.h"
 #include "TextException.h"
index 32b2e72f33df80cfdef28f637a6bda33f42208f8..cbfed7a3597e09aefb9cecd58949e6d3a5f2d2cd 100644 (file)
@@ -48,6 +48,7 @@
 #include "SwapDir.h"
 #include "icmp/net_db.h"
 #include "ip/IpAddress.h"
+#include "rfc1738.h"
 
 /// \ingroup ServerProtocolICPInternal2
 static void icpLogIcp(const IpAddress &, log_type, int, const char *, int);
index e886e9571070e638a9da9ece20d25c17adad7964..9e7968d80a9ed6a99c793306b221b236d54386d9 100644 (file)
@@ -34,6 +34,7 @@
 #include "comm.h"
 #include "fde.h"
 #include "ip/IpAddress.h"
+#include "rfc1738.h"
 
 static const char *hello_string = "hi there\n";
 #define HELLO_BUF_SZ 32
index 93fe7d43c89a47d299359e18be5031502c909ca6..04bbe8a08a2140a5549899953e6be5f0276bd4fe 100644 (file)
@@ -43,6 +43,7 @@
 #include "HttpRequest.h"
 #include "client_side.h"
 #include "helper.h"
+#include "rfc1738.h"
 
 typedef struct {
     void *data;
index 8e105266bc3f57c1187f6c53e6f62a10ae11a801..d9ac26f6d782e5a8eb59aef7a5b7b6e80d7a443e 100644 (file)
@@ -36,6 +36,7 @@
 #include "URL.h"
 #include "HttpRequest.h"
 #include "URLScheme.h"
+#include "rfc1738.h"
 
 static HttpRequest *urnParse(const HttpRequestMethod& method, char *urn);
 static const char valid_hostname_chars_u[] =
index 469bf7d22a8b497c166faf31e745b9f16dea99f2..513aea4c4f49ffca0644c2f9ff4878a44db3380b 100644 (file)
@@ -17,7 +17,7 @@ LDADD = \
        $(top_builddir)/src/globals.o \
        $(top_builddir)/src/time.o
 
-EXTRA_PROGRAMS = mem_node_test membanger splay tcp-banger2 rfc1738
+EXTRA_PROGRAMS = mem_node_test membanger splay tcp-banger2
 
 EXTRA_DIST = testheaders.sh
 
@@ -35,7 +35,6 @@ TESTS += debug \
        syntheticoperators \
        VirtualDeleteOperator \
        StackTest \
-       rfc1738 \
        refcount\
        splay\
        MemPoolTest\
@@ -50,7 +49,6 @@ check_PROGRAMS += debug \
                mem_node_test\
                mem_hdr_test \
                refcount\
-               rfc1738\
                splay \
                StackTest \
                syntheticoperators \
@@ -77,8 +75,6 @@ StackTest_SOURCES = StackTest.cc $(DEBUG_SOURCE)
 syntheticoperators_SOURCES = syntheticoperators.cc $(DEBUG_SOURCE)
 VirtualDeleteOperator_SOURCES = VirtualDeleteOperator.cc $(DEBUG_SOURCE)
 
-rfc1738_SOURCES = rfc1738.cc
-
 ## membanger won't link today. Bitrot..
 ##CC   = gcc
 ##CFLAGS       = -g -Wall -I../include -I../src
diff --git a/test-suite/rfc1738.cc b/test-suite/rfc1738.cc
deleted file mode 100644 (file)
index 1c4218c..0000000
+++ /dev/null
@@ -1,79 +0,0 @@
-
-/*
- * $Id$
- *
- * DEBUG: section xx    RFC 1738 string [un]escaping
- * AUTHOR:  Robert Collins
- *
- * SQUID Web Proxy Cache          http://www.squid-cache.org/
- * ----------------------------------------------------------
- *
- *  Squid is the result of efforts by numerous individuals from
- *  the Internet community; see the CONTRIBUTORS file for full
- *  details.   Many organizations have provided support for Squid's
- *  development; see the SPONSORS file for full details.  Squid is
- *  Copyrighted (C) 2001 by the Regents of the University of
- *  California; see the COPYRIGHT file for full details.  Squid
- *  incorporates software developed and/or copyrighted by other
- *  sources; see the CREDITS file for full details.
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
- *
- * Copyright (c) 2003 Robert Collins <robertc@squid-cache.org>
- */
-
-#include "squid.h"
-#include "util.h"
-/* testing:
-SQUIDCEXTERN char *rfc1738_escape(const char *);
-SQUIDCEXTERN char *rfc1738_escape_unescaped(const char *);
-SQUIDCEXTERN char *rfc1738_escape_part(const char *);
-SQUIDCEXTERN void rfc1738_unescape(char *);
-*/
-
-/* A corrupt string */
-#define BADSTRING "An Escaped %1"
-/* A partly corrupt string */
-#define CASE1 "An escaped %1A%3"
-#define RESULT1 "An escaped \032%3"
-/* A non corrupt string */
-#define GOODSTRING "An Escaped %1A"
-#define GOODUSTRING "An Escaped \032"
-
-void
-testAString(char const *aString, char const *aResult)
-{
-    char *escapedString;
-    escapedString = xstrdup (aString);
-    rfc1738_unescape(escapedString);
-    if (strcmp(escapedString, aResult))
-        exit (1);
-    safe_free (escapedString);
-}
-
-void
-testUnescaping()
-{
-    testAString(BADSTRING,BADSTRING);
-    testAString(GOODSTRING, GOODUSTRING);
-    testAString(CASE1, RESULT1);
-}
-
-int
-main (int argc, char **argv)
-{
-    testUnescaping();
-    return 0;
-}
index e71920c99116baa3d70e77f3d81e20dd6c084024..25800b8cf719c1e73c94968a623aa5ef962f7035 100644 (file)
@@ -31,6 +31,7 @@
  */
 
 #include "config.h"
+#include "rfc1738.h"
 
 #if HAVE_UNISTD_H
 #include <unistd.h>