fix url decode bug #2932

This commit is contained in:
xiongguangjie 2023-10-27 19:42:52 +08:00
parent 1a4b8406bb
commit 7c81cbb24a
1 changed files with 11 additions and 1 deletions

View File

@ -48,6 +48,9 @@ char StrToBin(const char *str) {
char chn; char chn;
tempWord[0] = CharToInt(str[0]); //make the B to 11 -- 00001011 tempWord[0] = CharToInt(str[0]); //make the B to 11 -- 00001011
tempWord[1] = CharToInt(str[1]); //make the 0 to 0 -- 00000000 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 chn = (tempWord[0] << 4) | tempWord[1]; //to change the BO to 10110000
return chn; return chn;
} }
@ -80,7 +83,14 @@ string strCoding::UrlDecode(const string &str) {
} }
tmp[0] = str[i + 1]; tmp[0] = str[i + 1];
tmp[1] = str[i + 2]; 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; i = i + 3;
} else { } else {
output += str[i]; output += str[i];