Skip to content

Commit 2e915c1

Browse files
authored
Use root locale when changing case in java
Not setting locale for language/country neutral operation may cause bug depending on the default locale. See https://docs.oracle.com/javase/7/docs/api/java/util/Locale.html#ROOT Note: I am just searching for toLowerCase() and toUppercase() in my project's dependencies and send the same PR, in order to potentially raise the awareness. Although I've seen the lack of explicit locale has caused issues for us, I am not sure if react-native-share is actually affected. Example related issue: joltup/rn-fetch-blob#573
1 parent f2d7c3b commit 2e915c1

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

android/src/main/java/cl/json/RNShareModule.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import com.facebook.react.bridge.Callback;
1515

1616
import java.util.HashMap;
17+
import java.util.Locale;
1718
import java.util.Map;
1819

1920
import cl.json.social.EmailShare;
@@ -141,7 +142,7 @@ public String getName() {
141142
public Map<String, Object> getConstants() {
142143
Map<String, Object> constants = new HashMap<>();
143144
for (SHARES val : SHARES.values()) {
144-
constants.put(val.toString().toUpperCase(), val.toString());
145+
constants.put(val.toString().toUpperCase(Locale.ROOT), val.toString());
145146
}
146147
return constants;
147148
}

0 commit comments

Comments
 (0)