Commit d03b0e4e authored by jan.koester's avatar jan.koester
Browse files

url decoding now robust

parent 707c1ef1
Loading
Loading
Loading
Loading
+8 −1
Changes for src/http.cpp: 8 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -1475,12 +1475,19 @@ void libhttppp::HttpForm::urlDecode(const std::string &in,std::string &out){
        switch(c)
        {
          case '%':
            if (i[1] && i[2]) {
            if ( ( i + 2 < nd ) && ( std::isxdigit(*(i + 1)) && std::isxdigit(*(i + 2)) ) ) {
                char hs[]{ i[1], i[2] };
                out.push_back(static_cast<char>(strtol(hs, nullptr, 16)));
                i += 2;
            }else{
                HTTPException e;
                e[HTTPException::Error] << "Wrong Decoded Url!";
                throw e;
            }
            break;
            case '+':
                out.push_back(' ');
            break;
            default:
                out.push_back(c);
        }