From 7c81cbb24a72dbb63fe4e10d3cf364181d07d5d6 Mon Sep 17 00:00:00 2001 From: xiongguangjie Date: Fri, 27 Oct 2023 19:42:52 +0800 Subject: [PATCH] fix url decode bug #2932 --- src/Common/strCoding.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Common/strCoding.cpp b/src/Common/strCoding.cpp index 144bf1f2..6695ecee 100644 --- a/src/Common/strCoding.cpp +++ b/src/Common/strCoding.cpp @@ -48,6 +48,9 @@ char StrToBin(const char *str) { char chn; tempWord[0] = CharToInt(str[0]); //make the B to 11 -- 00001011 tempWord[1] = CharToInt(str[1]); //make the 0 to 0 -- 00000000 + if(tempWord[0]<0 || tempWord[1]< 0){ + return -1; + } chn = (tempWord[0] << 4) | tempWord[1]; //to change the BO to 10110000 return chn; } @@ -80,7 +83,14 @@ string strCoding::UrlDecode(const string &str) { } tmp[0] = str[i + 1]; tmp[1] = str[i + 2]; - output += StrToBin(tmp); + char r = StrToBin(tmp); + if(r == -1){// % + output += str[i]; + output += tmp[0]; + output += tmp[1]; + }else{ + output += r; + } i = i + 3; } else { output += str[i];