This is an automated email from the ASF dual-hosted git repository.

GitToTheHub pushed a commit to branch 
pr-fix-ios-use-recommended-stringBy-methods
in repository https://gitbox.apache.org/repos/asf/cordova-plugin-file.git

commit c4c315534ea6ec5cbfc635c51fc476ad1b87b010
Author: Manuel Beck <[email protected]>
AuthorDate: Fri Jul 31 19:20:09 2026 +0200

    fix(ios): Use recommended `stringBy...` methods
    
    - Instead using the deprecated 
`stringByReplacingPercentEscapesUsingEncoding` method use 
`stringByRemovingPercentEncoding` which is available since iOS 7
    - Instead using the deprecated `stringByAddingPercentEscapesUsingEncoding` 
method use `stringByAddingPercentEncodingWithAllowedCharacters:` with the 
parameter `[NSCharacterSet URLPathAllowedCharacterSet]` which is available 
since iOS 7
---
 src/ios/CDVFile.m            | 4 ++--
 src/ios/CDVLocalFilesystem.m | 2 +-
 src/osx/CDVFile.m            | 4 ++--
 src/osx/CDVLocalFilesystem.m | 2 +-
 4 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/ios/CDVFile.m b/src/ios/CDVFile.m
index 59e7d64..30de3ee 100644
--- a/src/ios/CDVFile.m
+++ b/src/ios/CDVFile.m
@@ -586,8 +586,8 @@ NSString* const kCDVFilesystemURLPrefix = @"cdvfile";
 //encode path with percent escapes
 -(NSString *)encodePath:(NSString *)path
 {
-    NSString *decodedPath = [path 
stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; //decode 
incase it's already encoded to avoid encoding twice
-    return [decodedPath 
stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
+    NSString *decodedPath = [path stringByRemovingPercentEncoding]; //decode 
incase it's already encoded to avoid encoding twice
+    return [decodedPath 
stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet 
URLPathAllowedCharacterSet]];
 }
 
 
diff --git a/src/ios/CDVLocalFilesystem.m b/src/ios/CDVLocalFilesystem.m
index c340ce0..4ba1fb0 100644
--- a/src/ios/CDVLocalFilesystem.m
+++ b/src/ios/CDVLocalFilesystem.m
@@ -125,7 +125,7 @@
 - (CDVFilesystemURL *)URLforFullPath:(NSString *)fullPath
 {
     if (fullPath) {
-        NSString* escapedPath = [fullPath 
stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
+        NSString* escapedPath = [fullPath 
stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet 
URLPathAllowedCharacterSet]];
         if ([fullPath hasPrefix:@"/"]) {
             return [CDVFilesystemURL fileSystemURLWithString:[NSString 
stringWithFormat:@"%@://localhost/%@%@", kCDVFilesystemURLPrefix, self.name, 
escapedPath]];
         }
diff --git a/src/osx/CDVFile.m b/src/osx/CDVFile.m
index 75a6001..1e26440 100644
--- a/src/osx/CDVFile.m
+++ b/src/osx/CDVFile.m
@@ -535,8 +535,8 @@ NSString* const kCDVFilesystemURLPrefix = @"cdvfile";
 //encode path with percent escapes
 -(NSString *)encodePath:(NSString *)path
 {
-    NSString *decodedPath = [path 
stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; //decode 
incase it's already encoded to avoid encoding twice
-    return [decodedPath 
stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
+    NSString *decodedPath = [path stringByRemovingPercentEncoding]; //decode 
incase it's already encoded to avoid encoding twice
+    return [decodedPath 
stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet 
URLPathAllowedCharacterSet]];
 }
 
 
diff --git a/src/osx/CDVLocalFilesystem.m b/src/osx/CDVLocalFilesystem.m
index 016e399..e2fe2ae 100644
--- a/src/osx/CDVLocalFilesystem.m
+++ b/src/osx/CDVLocalFilesystem.m
@@ -123,7 +123,7 @@
 - (CDVFilesystemURL *)URLforFullPath:(NSString *)fullPath
 {
     if (fullPath) {
-        NSString* escapedPath = [fullPath 
stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
+        NSString* escapedPath = [fullPath 
stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet 
URLPathAllowedCharacterSet]];
         if ([fullPath hasPrefix:@"/"]) {
             return [CDVFilesystemURL fileSystemURLWithString:[NSString 
stringWithFormat:@"%@://localhost/%@%@", kCDVFilesystemURLPrefix, self.name, 
escapedPath]];
         }


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to