| 240 | return Result; |
| 241 | } |
| 242 | string PercentDecode(const string& In) |
| 243 | { |
| 244 | string Result; |
| 245 | Result.reserve(In.size()); |
| 246 | for (string::size_type i=0; i<In.size(); i++) |
| 247 | { |
| 248 | char C=In[i]; |
| 249 | switch (C) |
| 250 | { |
| 251 | case '%': |
| 252 | { |
| 253 | if (i+2>In.size()) |
| 254 | return In; |
| 255 | char C1=In[++i]; |
| 256 | if (!((C1>='0' && C1<='9') |
| 257 | || (C1>='A' && C1<='F') |
| 258 | || (C1>='a' && C1<='f'))) |
| 259 | return In; |
| 260 | char C2=In[++i]; |
| 261 | if (!((C2>='0' && C2<='9') |
| 262 | || (C2>='A' && C2<='F') |
| 263 | || (C2>='a' && C2<='f'))) |
| 264 | return In; |
| 265 | if (C1>='a') |
| 266 | C1-='a'-10; |
| 267 | else if (C1>='A') |
| 268 | C1-='A'-10; |
| 269 | else |
| 270 | C1-='0'; |
| 271 | if (C2>='a') |
| 272 | C2-='a'-10; |
| 273 | else if (C2>='A') |
| 274 | C2-='A'-10; |
| 275 | else |
| 276 | C2-='0'; |
| 277 | Result+=(const char)((C1<<4)|C2); |
| 278 | continue; |
| 279 | } |
| 280 | default: |
| 281 | Result+=C; |
| 282 | } |
| 283 | } |
| 284 | return Result; |
| 285 | } |
| 286 | MediaInfo_Config::urlencode DetectPercentEncode(const string& In, bool AcceptSlash=false) |
| 287 | { |
| 288 | MediaInfo_Config::urlencode Result=MediaInfo_Config::URLEncode_Guess; |
no test coverage detected