Skip to content

Commit

Permalink
fix(android): use Locale.ROOT when changing case in java (#1152)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
mobiledev7 committed Feb 2, 2022
1 parent b03fbf9 commit 3eaf885
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion android/src/main/java/cl/json/RNShareModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import com.facebook.react.bridge.Callback;

import java.util.HashMap;
import java.util.Locale;
import java.util.Map;

import cl.json.social.EmailShare;
Expand Down Expand Up @@ -141,7 +142,7 @@ public String getName() {
public Map<String, Object> getConstants() {
Map<String, Object> constants = new HashMap<>();
for (SHARES val : SHARES.values()) {
constants.put(val.toString().toUpperCase(), val.toString());
constants.put(val.toString().toUpperCase(Locale.ROOT), val.toString());
}
return constants;
}
Expand Down

0 comments on commit 3eaf885

Please sign in to comment.