(@Nullable String s)
| 1092 | } |
| 1093 | |
| 1094 | @Nullable |
| 1095 | private static String percentDecodeAssumedUtf8(@Nullable String s) { |
| 1096 | if (s == null || s.indexOf('%') == -1) { |
| 1097 | return s; |
| 1098 | } |
| 1099 | |
| 1100 | ByteBuffer utf8Bytes = percentDecode(s); |
| 1101 | try { |
| 1102 | return StandardCharsets.UTF_8 |
| 1103 | .newDecoder() |
| 1104 | .onMalformedInput(CodingErrorAction.REPLACE) |
| 1105 | .onUnmappableCharacter(CodingErrorAction.REPLACE) |
| 1106 | .decode(utf8Bytes) |
| 1107 | .toString(); |
| 1108 | } catch (CharacterCodingException e) { |
| 1109 | throw new VerifyException(e); // Should not happen in REPLACE mode. |
| 1110 | } |
| 1111 | } |
| 1112 | |
| 1113 | @Nullable |
| 1114 | private static String percentEncode(String s, BitSet allowedCodePoints) { |
no test coverage detected