[PATCH] Polipo doesn't write to disk when "HTTP://" scheme is uppercase

David Röthlisberger <[email protected]>
Newsgroups gmane.comp.web.polipo.user
Message-ID <[email protected]>
We have a client that is sending GET requests with a URL containing an
uppercase scheme name. Polipo does cache the instance in memory, but was
not writing it to disk (which prevented it being cached across polipo
restarts).

The client is incorrect because RFC 2616 says in section 3.2.2:

    http_URL = "http:" "//" host [ ":" port ] [ abs_path [ "?" query ]]

But polipo is also incorrect because section 3.2.3 says:

    Comparisons of scheme names MUST be case-insensitive

Patch attached.

Cheers,
Dave.

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/

_______________________________________________
Polipo-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/polipo-users
0001-Cache-to-disk-even-when-HTTP-scheme-is-uppercase.patch (application/octet-stream, 1.5 KB)
From 9b016e6125a86eead9896fb524743b0d0b19a6b0 Mon Sep 17 00:00:00 2001
From: David Rothlisberger <[email protected]>
Date: Wed, 5 Sep 2012 13:50:15 +0100
Subject: [PATCH] Cache to disk even when "HTTP://" scheme is uppercase

We have a client that is sending GET requests with a URL containing an
uppercase scheme name. Polipo does cache the instance in memory, but was
not writing it to disk (which prevented it being cached across polipo
restarts).

The client is incorrect because RFC 2616 says in section 3.2.2:

    http_URL = "http:" "//" host [ ":" port ] [ abs_path [ "?" query ]]

But polipo is also incorrect because section 3.2.3 says:

    Comparisons of scheme names MUST be case-insensitive
---
 diskcache.c | 2 +-
 forbidden.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/diskcache.c b/diskcache.c
index a453e46..baaf079 100644
--- a/diskcache.c
+++ b/diskcache.c
@@ -366,7 +366,7 @@ urlDirname(char *buf, int n, const char *url, int len)
     int i, j;
     if(len < 8)
         return -1;
-    if(memcmp(url, "http://", 7) != 0)
+    if(lwrcmp(url, "http://", 7) != 0)
         return -1;
 
     if(diskCacheRoot == NULL ||
diff --git a/forbidden.c b/forbidden.c
index f27019b..4b9fa36 100644
--- a/forbidden.c
+++ b/forbidden.c
@@ -398,7 +398,7 @@ urlIsMatched(char *url, int length, DomainPtr *domains, regex_t *regex)
     if(length < 8)
         return 0;
 
-    if(memcmp(url, "http://", 7) != 0)
+    if(lwrcmp(url, "http://", 7) != 0)
         return 0;
 
     if(domains) {
-- 
1.7.11.5
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.