summaryrefslogtreecommitdiffabout
authorMichael Krelin <hacker@klever.net>2009-09-01 19:59:38 (UTC)
committer Michael Krelin <hacker@klever.net>2009-09-01 19:59:38 (UTC)
commitda3fe98e5c75940135fcd9bb45b36eed62d8b4dc (patch) (unidiff)
treeeda546a705a667dd1b62f7eee481b3087fbfdf27
parent34d57b6b55b51e4b489a4cafce8874dec558b600 (diff)
downloadlibopkele-da3fe98e5c75940135fcd9bb45b36eed62d8b4dc.zip
libopkele-da3fe98e5c75940135fcd9bb45b36eed62d8b4dc.tar.gz
libopkele-da3fe98e5c75940135fcd9bb45b36eed62d8b4dc.tar.bz2
fixed normalization for the single-character trailing component
Thanks Hiroyuki ARAKI for spotting the bug and providing the fix Signed-off-by: Michael Krelin <hacker@klever.net>
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--lib/util.cc2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/util.cc b/lib/util.cc
index 249eeed..4028697 100644
--- a/lib/util.cc
+++ b/lib/util.cc
@@ -363,25 +363,25 @@ namespace opkele {
363 throw bad_input(OPKELE_CP_ "Invalid percent-encoded character in URI being normalized"); 363 throw bad_input(OPKELE_CP_ "Invalid percent-encoded character in URI being normalized");
364 int cc = strtol(tmp,0,16); 364 int cc = strtol(tmp,0,16);
365 if( isalpha(cc) || isdigit(cc) || strchr("._~-",cc) ) 365 if( isalpha(cc) || isdigit(cc) || strchr("._~-",cc) )
366 pseg += (char)cc; 366 pseg += (char)cc;
367 else{ 367 else{
368 pseg += '%'; 368 pseg += '%';
369 pseg += (char)toupper(tmp[0]); pseg += (char)toupper(tmp[1]); 369 pseg += (char)toupper(tmp[0]); pseg += (char)toupper(tmp[1]);
370 } 370 }
371 }else if(qf) { 371 }else if(qf) {
372 rv += pseg; rv += c; 372 rv += pseg; rv += c;
373 pseg.clear(); 373 pseg.clear();
374 }else if(n>=ul || strchr("?/#",c)) { 374 }else if(n>=ul || strchr("?/#",c)) {
375 if(pseg.empty() || pseg==".") { 375 if( (unsafe!=string::npos && pseg.empty()) || pseg==".") {
376 }else if(pseg=="..") { 376 }else if(pseg=="..") {
377 if(psegs.size()>1) { 377 if(psegs.size()>1) {
378 rv.resize(psegs.top()); psegs.pop(); 378 rv.resize(psegs.top()); psegs.pop();
379 } 379 }
380 }else{ 380 }else{
381 psegs.push(rv.length()); 381 psegs.push(rv.length());
382 if(c!='/') { 382 if(c!='/') {
383 pseg += c; 383 pseg += c;
384 qf = true; 384 qf = true;
385 } 385 }
386 rv += '/'; rv += pseg; 386 rv += '/'; rv += pseg;
387 } 387 }