]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Bug 1961, Bug 429: Add asterisk to class URL
authorAmos Jeffries <squid3@treenet.co.nz>
Thu, 18 Dec 2014 12:12:33 +0000 (01:12 +1300)
committerAmos Jeffries <squid3@treenet.co.nz>
Thu, 18 Dec 2014 12:12:33 +0000 (01:12 +1300)
This does not yet perform any of the outgoing request mapping from
path-less URI required by current RFC 7231.

Squid already allows these URI in OPTIONS and TRACE requests (only).

It does make a start by cleaning up the current special case handling of
"*" URI to be matched by the URI class/namespace method and SBuf
comparisions instead of c-strings.

src/URL.h
src/url.cc

index f58835f0714e9071bd6e35cc239b55b7edfe3aac..c17d59ab78f5be865f2420b0dda05e027e4f5020 100644 (file)
--- a/src/URL.h
+++ b/src/URL.h
@@ -35,6 +35,9 @@ public:
     void userInfo(const SBuf &s) {userInfo_=s;}
     const SBuf &userInfo() const {return userInfo_;}
 
+    /// the static '*' pseudo-URL
+    static const SBuf &Asterisk();
+
 private:
     /**
      \par
index 0a858eef26d32912ee2b0e32fc52f118dc6a318c..3f62013b3b273b8ecc1200947763997d09cf636d 100644 (file)
@@ -37,6 +37,13 @@ static const char valid_hostname_chars[] =
     "[:]"
     ;
 
+const SBuf &
+URL::Asterisk()
+{
+    static SBuf star("*");
+    return star;
+}
+
 void
 urlInitialize(void)
 {
@@ -215,7 +222,7 @@ urlParse(const HttpRequestMethod& method, char *url, HttpRequest *request)
                 return NULL;
 
     } else if ((method == Http::METHOD_OPTIONS || method == Http::METHOD_TRACE) &&
-               strcmp(url, "*") == 0) {
+               URL::Asterisk().cmp(url) == 0) {
         protocol = AnyP::PROTO_HTTP;
         port = urlDefaultPort(protocol);
         return urlParseFinish(method, protocol, url, host, SBuf(), port, request);
@@ -794,7 +801,7 @@ urlCheckRequest(const HttpRequest * r)
     // we support OPTIONS and TRACE directed at us (with a 501 reply, for now)
     // we also support forwarding OPTIONS and TRACE, except for the *-URI ones
     if (r->method == Http::METHOD_OPTIONS || r->method == Http::METHOD_TRACE)
-        return (r->header.getInt64(HDR_MAX_FORWARDS) == 0 || r->urlpath != "*");
+        return (r->header.getInt64(HDR_MAX_FORWARDS) == 0 || URL::Asterisk().cmp(r->urlpath.rawBuf(), r->urlpath.size()) != 0);
 
     if (r->method == Http::METHOD_PURGE)
         return 1;