@capacitor/android 6.2.0 → 6.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -497,6 +497,15 @@ var nativeBridge = (function (exports) {
|
|
|
497
497
|
if (doPatchHttp) {
|
|
498
498
|
// fetch patch
|
|
499
499
|
window.fetch = async (resource, options) => {
|
|
500
|
+
const headers = new Headers(options === null || options === void 0 ? void 0 : options.headers);
|
|
501
|
+
const contentType = headers.get('Content-Type') || headers.get('content-type');
|
|
502
|
+
if ((options === null || options === void 0 ? void 0 : options.body) instanceof FormData &&
|
|
503
|
+
(contentType === null || contentType === void 0 ? void 0 : contentType.includes('multipart/form-data')) &&
|
|
504
|
+
!contentType.includes('boundary')) {
|
|
505
|
+
headers.delete('Content-Type');
|
|
506
|
+
headers.delete('content-type');
|
|
507
|
+
options.headers = headers;
|
|
508
|
+
}
|
|
500
509
|
const request = new Request(resource, options);
|
|
501
510
|
if (request.url.startsWith(`${cap.getServerUrl()}/`)) {
|
|
502
511
|
return win.CapacitorWebFetch(resource, options);
|
|
@@ -219,7 +219,8 @@ public class FileUtils {
|
|
|
219
219
|
int nameIndex = cursor.getColumnIndex(OpenableColumns.DISPLAY_NAME);
|
|
220
220
|
cursor.moveToFirst();
|
|
221
221
|
String name = (cursor.getString(nameIndex));
|
|
222
|
-
|
|
222
|
+
String fileName = sanitizeFilename(name);
|
|
223
|
+
File file = new File(context.getFilesDir(), fileName);
|
|
223
224
|
try {
|
|
224
225
|
InputStream inputStream = context.getContentResolver().openInputStream(uri);
|
|
225
226
|
FileOutputStream outputStream = new FileOutputStream(file);
|
|
@@ -289,4 +290,14 @@ public class FileUtils {
|
|
|
289
290
|
}
|
|
290
291
|
return null;
|
|
291
292
|
}
|
|
293
|
+
|
|
294
|
+
private static String sanitizeFilename(String displayName) {
|
|
295
|
+
String[] badCharacters = new String[] { "..", "/" };
|
|
296
|
+
String[] segments = displayName.split("/");
|
|
297
|
+
String fileName = segments[segments.length - 1];
|
|
298
|
+
for (String suspString : badCharacters) {
|
|
299
|
+
fileName = fileName.replace(suspString, "_");
|
|
300
|
+
}
|
|
301
|
+
return fileName;
|
|
302
|
+
}
|
|
292
303
|
}
|
package/package.json
CHANGED