-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Android: Fixes #10681: Fix Dropbox sync for certain device languages #10759
Merged
laurent22
merged 4 commits into
laurent22:dev
from
personalizedrefrigerator:pr/mobile/patch-fix-dropbox-sync-tr
Jul 18, 2024
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
dc69c0d
Fix Dropbox sync in certain locales by patching rn-fetch-blob
personalizedrefrigerator c172cb5
Merge remote-tracking branch 'upstream/dev' into pr/mobile/patch-fix-…
personalizedrefrigerator e03f983
Fix patch
personalizedrefrigerator f6a924e
Commenting: Explain reason for patch
personalizedrefrigerator File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
118 changes: 118 additions & 0 deletions
118
.yarn/patches/rn-fetch-blob-npm-0.12.0-cf02e3c544.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
# Fixes sync issues caused by locale-sensitive lowercasing | ||
# of HTTP headers. | ||
# See https://github.com/laurent22/joplin/issues/10681 | ||
diff --git a/android/src/main/java/com/RNFetchBlob/RNFetchBlobConfig.java b/android/src/main/java/com/RNFetchBlob/RNFetchBlobConfig.java | ||
index 8ac9e7a855162cefbf99024eb013c8a3b11de1ec..1c639cf9d84821b6ffc132960e2d1c044bedbd48 100644 | ||
--- a/android/src/main/java/com/RNFetchBlob/RNFetchBlobConfig.java | ||
+++ b/android/src/main/java/com/RNFetchBlob/RNFetchBlobConfig.java | ||
@@ -2,6 +2,7 @@ package com.RNFetchBlob; | ||
|
||
import com.facebook.react.bridge.ReadableArray; | ||
import com.facebook.react.bridge.ReadableMap; | ||
+import java.util.Locale; | ||
|
||
class RNFetchBlobConfig { | ||
|
||
@@ -33,7 +34,7 @@ class RNFetchBlobConfig { | ||
} | ||
if(options.hasKey("binaryContentTypes")) | ||
this.binaryContentTypes = options.getArray("binaryContentTypes"); | ||
- if(this.path != null && path.toLowerCase().contains("?append=true")) { | ||
+ if(this.path != null && path.toLowerCase(Locale.ROOT).contains("?append=true")) { | ||
this.overwrite = false; | ||
} | ||
if(options.hasKey("overwrite")) | ||
diff --git a/android/src/main/java/com/RNFetchBlob/RNFetchBlobFS.java b/android/src/main/java/com/RNFetchBlob/RNFetchBlobFS.java | ||
index a4d70153f41e6c14eec65412b5b59822f1c6750b..d98c439f7b0aeb79afc82ab9f653e9c021086426 100644 | ||
--- a/android/src/main/java/com/RNFetchBlob/RNFetchBlobFS.java | ||
+++ b/android/src/main/java/com/RNFetchBlob/RNFetchBlobFS.java | ||
@@ -29,6 +29,7 @@ import java.util.ArrayList; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
import java.util.UUID; | ||
+import java.util.Locale; | ||
|
||
class RNFetchBlobFS { | ||
|
||
@@ -210,7 +211,7 @@ class RNFetchBlobFS { | ||
return; | ||
} | ||
|
||
- switch (encoding.toLowerCase()) { | ||
+ switch (encoding.toLowerCase(Locale.ROOT)) { | ||
case "base64" : | ||
promise.resolve(Base64.encodeToString(bytes, Base64.NO_WRAP)); | ||
break; | ||
@@ -1050,7 +1051,7 @@ class RNFetchBlobFS { | ||
if(encoding.equalsIgnoreCase("ascii")) { | ||
return data.getBytes(Charset.forName("US-ASCII")); | ||
} | ||
- else if(encoding.toLowerCase().contains("base64")) { | ||
+ else if(encoding.toLowerCase(Locale.ROOT).contains("base64")) { | ||
return Base64.decode(data, Base64.NO_WRAP); | ||
|
||
} | ||
diff --git a/android/src/main/java/com/RNFetchBlob/RNFetchBlobReq.java b/android/src/main/java/com/RNFetchBlob/RNFetchBlobReq.java | ||
index a8abd71833879201e3438b2fa51d712a311c4551..b70cc13c004229f69157de5f82ae5ec3abf4358e 100644 | ||
--- a/android/src/main/java/com/RNFetchBlob/RNFetchBlobReq.java | ||
+++ b/android/src/main/java/com/RNFetchBlob/RNFetchBlobReq.java | ||
@@ -49,6 +49,7 @@ import java.security.KeyStore; | ||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
+import java.util.Locale; | ||
import java.util.HashMap; | ||
|
||
import java.util.concurrent.TimeUnit; | ||
@@ -300,14 +301,14 @@ public class RNFetchBlobReq extends BroadcastReceiver implements Runnable { | ||
responseFormat = ResponseFormat.UTF8; | ||
} | ||
else { | ||
- builder.header(key.toLowerCase(), value); | ||
- mheaders.put(key.toLowerCase(), value); | ||
+ builder.header(key.toLowerCase(Locale.ROOT), value); | ||
+ mheaders.put(key.toLowerCase(Locale.ROOT), value); | ||
} | ||
} | ||
} | ||
|
||
if(method.equalsIgnoreCase("post") || method.equalsIgnoreCase("put") || method.equalsIgnoreCase("patch")) { | ||
- String cType = getHeaderIgnoreCases(mheaders, "Content-Type").toLowerCase(); | ||
+ String cType = getHeaderIgnoreCases(mheaders, "Content-Type").toLowerCase(Locale.ROOT); | ||
|
||
if(rawRequestBodyArray != null) { | ||
requestType = RequestType.Form; | ||
@@ -323,7 +324,7 @@ public class RNFetchBlobReq extends BroadcastReceiver implements Runnable { | ||
|| rawRequestBody.startsWith(RNFetchBlobConst.CONTENT_PREFIX)) { | ||
requestType = RequestType.SingleFile; | ||
} | ||
- else if (cType.toLowerCase().contains(";base64") || cType.toLowerCase().startsWith("application/octet")) { | ||
+ else if (cType.toLowerCase(Locale.ROOT).contains(";base64") || cType.toLowerCase(Locale.ROOT).startsWith("application/octet")) { | ||
cType = cType.replace(";base64","").replace(";BASE64",""); | ||
if(mheaders.containsKey("content-type")) | ||
mheaders.put("content-type", cType); | ||
@@ -686,7 +687,7 @@ public class RNFetchBlobReq extends BroadcastReceiver implements Runnable { | ||
boolean isCustomBinary = false; | ||
if(options.binaryContentTypes != null) { | ||
for(int i = 0; i< options.binaryContentTypes.size();i++) { | ||
- if(ctype.toLowerCase().contains(options.binaryContentTypes.getString(i).toLowerCase())) { | ||
+ if(ctype.toLowerCase(Locale.ROOT).contains(options.binaryContentTypes.getString(i).toLowerCase(Locale.ROOT))) { | ||
isCustomBinary = true; | ||
break; | ||
} | ||
@@ -698,13 +699,13 @@ public class RNFetchBlobReq extends BroadcastReceiver implements Runnable { | ||
private String getHeaderIgnoreCases(Headers headers, String field) { | ||
String val = headers.get(field); | ||
if(val != null) return val; | ||
- return headers.get(field.toLowerCase()) == null ? "" : headers.get(field.toLowerCase()); | ||
+ return headers.get(field.toLowerCase(Locale.ROOT)) == null ? "" : headers.get(field.toLowerCase(Locale.ROOT)); | ||
} | ||
|
||
private String getHeaderIgnoreCases(HashMap<String,String> headers, String field) { | ||
String val = headers.get(field); | ||
if(val != null) return val; | ||
- String lowerCasedValue = headers.get(field.toLowerCase()); | ||
+ String lowerCasedValue = headers.get(field.toLowerCase(Locale.ROOT)); | ||
return lowerCasedValue == null ? "" : lowerCasedValue; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for fixing this! Could you please add a comment at the top explaining what the patch is for? I think you can add comments by prefixing them with
#