From eb806f4c14a1ec98045cfde56fcf1079ebc727c0 Mon Sep 17 00:00:00 2001 From: "John J. Aylward" Date: Fri, 10 Feb 2017 10:07:28 -0500 Subject: [PATCH] make sure locale independent data is not upper/lowercased incorrectly. See #315 --- HTTP.java | 3 ++- JSONObject.java | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/HTTP.java b/HTTP.java index b14d04e..9b444ce 100644 --- a/HTTP.java +++ b/HTTP.java @@ -25,6 +25,7 @@ SOFTWARE. */ import java.util.Iterator; +import java.util.Locale; /** * Convert an HTTP header to a JSONObject and back. @@ -74,7 +75,7 @@ public class HTTP { String token; token = x.nextToken(); - if (token.toUpperCase().startsWith("HTTP")) { + if (token.toUpperCase(Locale.ROOT).startsWith("HTTP")) { // Response diff --git a/JSONObject.java b/JSONObject.java index 4df256a..1eab694 100644 --- a/JSONObject.java +++ b/JSONObject.java @@ -1157,9 +1157,9 @@ public class JSONObject { && Character.isUpperCase(key.charAt(0)) && method.getParameterTypes().length == 0) { if (key.length() == 1) { - key = key.toLowerCase(); + key = key.toLowerCase(Locale.ROOT); } else if (!Character.isUpperCase(key.charAt(1))) { - key = key.substring(0, 1).toLowerCase() + key = key.substring(0, 1).toLowerCase(Locale.ROOT) + key.substring(1); }