Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

mobile: fix attachments fail to encrypt from share extension

ammarahm-ed2e7b5d0d0843
diff --git a/apps/mobile/app/utils/note-bundle.js b/apps/mobile/app/utils/note-bundle.js
index 3a41395c4..d9e6f1a49 100644
--- a/apps/mobile/app/utils/note-bundle.js
+++ b/apps/mobile/app/utils/note-bundle.js
@@ -24,6 +24,12 @@ import RNFetchBlob from "react-native-blob-util";
import { db } from "../common/database";
import { IOS_APPGROUPID } from "./constants";
+const santizeUri = (uri) => {
+ uri = decodeURI(uri);
+ uri = Platform.OS === "ios" ? uri.replace("file:///", "/") : uri;
+ return uri;
+};
+
export async function attachFile(uri, hash, type, filename, options) {
try {
let exists = db.attachments.exists(hash);
@@ -76,9 +82,7 @@ async function createNotes(bundle) {
for (const file of bundle.files) {
const uri =
- Platform.OS === "ios"
- ? `${file.value.replace("file://", "")}`
- : `${file.value}`;
+ Platform.OS === "ios" ? santizeUri(file.value) : `${file.value}`;
const hash = await Sodium.hashFile({
uri: uri,
type: "cache"
diff --git a/apps/mobile/native/package.json b/apps/mobile/native/package.json
index bd89555d9..e10d98745 100644
--- a/apps/mobile/native/package.json
+++ b/apps/mobile/native/package.json
@@ -7,7 +7,7 @@
"dependencies": {
"@ammarahmed/notifee-react-native": "7.4.4",
"@ammarahmed/react-native-share-extension": "^2.5.5",
- "@ammarahmed/react-native-sodium": "1.5.2",
+ "@ammarahmed/react-native-sodium": "1.5.3",
"@bam.tech/react-native-image-resizer": "3.0.5",
"@callstack/repack": "^3.2.0",
"@react-native-clipboard/clipboard": "^1.9.0",