| 4691 | } |
| 4692 | |
| 4693 | String String::uri_file_decode() const { |
| 4694 | CharString src = utf8(); |
| 4695 | CharString res; |
| 4696 | for (int i = 0; i < src.length(); ++i) { |
| 4697 | if (src[i] == '%' && i + 2 < src.length()) { |
| 4698 | char ord1 = src[i + 1]; |
| 4699 | if (is_digit(ord1) || is_ascii_upper_case(ord1)) { |
| 4700 | char ord2 = src[i + 2]; |
| 4701 | if (is_digit(ord2) || is_ascii_upper_case(ord2)) { |
| 4702 | char bytes[3] = { (char)ord1, (char)ord2, 0 }; |
| 4703 | res += (char)strtol(bytes, nullptr, 16); |
| 4704 | i += 2; |
| 4705 | } |
| 4706 | } else { |
| 4707 | res += src[i]; |
| 4708 | } |
| 4709 | } else { |
| 4710 | res += src[i]; |
| 4711 | } |
| 4712 | } |
| 4713 | return String::utf8(res); |
| 4714 | } |
| 4715 | |
| 4716 | String String::c_unescape() const { |
| 4717 | String escaped = *this; |
no test coverage detected