summaryrefslogtreecommitdiffabout
path: root/lib
authorMichael Krelin <hacker@klever.net>2007-01-09 20:04:29 (UTC)
committer Michael Krelin <hacker@klever.net>2007-01-09 20:04:29 (UTC)
commit46fa1790c6d5e990030d8b2b7ae07cb150a49730 (patch) (side-by-side diff)
tree115419ff78232cfec478222b372d8c60e15dd0fc /lib
parentadc2d682fa4f0aa83b4359bb212eda616cbe39dd (diff)
downloadlibopkele-46fa1790c6d5e990030d8b2b7ae07cb150a49730.zip
libopkele-46fa1790c6d5e990030d8b2b7ae07cb150a49730.tar.gz
libopkele-46fa1790c6d5e990030d8b2b7ae07cb150a49730.tar.bz2
canonicalization bug - do not add '/' after '?', add it right after hostname if needed.
Diffstat (limited to 'lib') (more/less context) (ignore whitespace changes)
-rw-r--r--lib/consumer.cc11
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/consumer.cc b/lib/consumer.cc
index cbe0769..bb6358c 100644
--- a/lib/consumer.cc
+++ b/lib/consumer.cc
@@ -320,22 +320,29 @@ namespace opkele {
if(i==string::npos)
throw bad_input(OPKELE_CP_ "empty URL");
if(i)
rv.erase(0,i);
i = rv.find_last_not_of(" \t\r\n");
assert(i!=string::npos);
if(i<(rv.length()-1))
rv.erase(i+1);
// add missing http://
i = rv.find("://");
if(i==string::npos) { // primitive. but do we need more?
rv.insert(0,"http://");
i = sizeof("http://")-1;
}else{
i += sizeof("://")-1;
}
- if(rv.find('/',i)==string::npos)
- rv += '/';
+ string::size_type qm = rv.find('?',i);
+ string::size_type sl = rv.find('/',i);
+ if(qm!=string::npos) {
+ if(sl==string::npos || sl>qm)
+ rv.insert(qm,1,'/');
+ }else{
+ if(sl==string::npos)
+ rv += '/';
+ }
return rv;
}
}