amarkevich commented on a change in pull request #900: URL: https://github.com/apache/cxf/pull/900#discussion_r800251391
########## File path: rt/rs/extensions/json-basic/src/main/java/org/apache/cxf/jaxrs/json/basic/JsonMapObjectReaderWriter.java ########## @@ -384,26 +401,38 @@ public Output append(char ch) { } - private String escapeJson(String value) { + private String escapeJson(String content) { StringBuilder sb = new StringBuilder(); - for (int i = 0; i < value.length(); i++) { - char c = value.charAt(i); - // If we have " and the previous char was not \ then escape it - if (c == '"' && (i == 0 || value.charAt(i - 1) != '\\')) { - sb.append('\\').append(c); - // If we have \ and the previous char was not \ and the next char is not an escaped char, then escape it - } else if (c == '\\' && (i == 0 || value.charAt(i - 1) != '\\') - && (i == value.length() - 1 || !isEscapedChar(value.charAt(i + 1)))) { - sb.append('\\').append(c); - } else { + final int[] escCodes = sOutputEscapes128; + int escLen = escCodes.length; + for (int i = 0, len = content.length(); i < len; ++i) { + char c = content.charAt(i); + if (c >= escLen || escCodes[c] == 0) { Review comment: since only first 32 characters escaped `escCodes[c] == 0` can be removed using table with size 32 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: dev-unsubscr...@cxf.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org