Skip to content

Commit

Permalink
CLDR-16192 Admin email encoding failure for non-ASCII text (#2599)
Browse files Browse the repository at this point in the history
-Simply return parameter unchanged for WebContext.decodeFieldString

-Comments
  • Loading branch information
btangmu authored Feb 28, 2023
1 parent 9258c90 commit 927fa15
Showing 1 changed file with 8 additions and 24 deletions.
32 changes: 8 additions & 24 deletions tools/cldr-apps/src/main/java/org/unicode/cldr/web/WebContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -291,34 +291,18 @@ public String field(String x, String def) {
}

/*
* Decode a single string from URL format into Unicode
* Return the input string, unchanged
*
* @param res UTF-8 'encoded' bytes (expanded to a string)
* This method no longer serves any purpose since CLDR now requires UTF-8 encoding
* for all http requests and related services/configuration.
*
* @return Unicode string (will return 'res' if no high bits were detected)
* This method is temporarily retained for compatibility with legacy code including .jsp.
*
* @param res the string
*
* @return the string
*/
public static String decodeFieldString(String res) {
if (res == null)
return null;
byte[] asBytes = new byte[res.length()];
boolean wasHigh = false;
int n;
for (n = 0; n < res.length(); n++) {
asBytes[n] = (byte) (res.charAt(n) & 0x00FF);
// println(" n : " + (int)asBytes[n] + " .. ");
if (asBytes[n] < 0) {
wasHigh = true;
}
}
if (!wasHigh) {
return res; // no utf-8
}
try {
res = new String(asBytes, StandardCharsets.UTF_8);
} catch (Throwable t) {
return res;
}

return res;
}

Expand Down

0 comments on commit 927fa15

Please sign in to comment.