Brion VIBBER has uploaded a new change for review.
https://gerrit.wikimedia.org/r/183901
Change subject: Use more human-readable directory names for articles
......................................................................
Use more human-readable directory names for articles
Was percent-encoding titles, which made non-ASCII titles into
long illegible dirs. Only actually need to escape the "/" and the
"%" as the rest of chars are legit filesystem chars.
Change-Id: I8e663ab8607352f51e6766bf2d31238299123a39
---
M MediaWikiKit/MediaWikiKit/MWKDataStore.m
M MediaWikiKit/MediaWikiKitTests/MWKDataStorePathTests.m
2 files changed, 4 insertions(+), 7 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/apps/ios/wikipedia
refs/changes/01/183901/1
diff --git a/MediaWikiKit/MediaWikiKit/MWKDataStore.m
b/MediaWikiKit/MediaWikiKit/MWKDataStore.m
index 86fadf7..1573c36 100644
--- a/MediaWikiKit/MediaWikiKit/MWKDataStore.m
+++ b/MediaWikiKit/MediaWikiKit/MWKDataStore.m
@@ -94,12 +94,9 @@
-(NSString *)safeFilenameWithString:(NSString *)str
{
- // This handy function does most of the percent-escaping
- NSString *encodedStr = [str
stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
-
- // But it leaves "/" and "&" intact. Naughty!
+ // Escape only % and / with percent style for readability
+ NSString *encodedStr = [str stringByReplacingOccurrencesOfString:@"%"
withString:@"%25"];
encodedStr = [encodedStr stringByReplacingOccurrencesOfString:@"/"
withString:@"%2F"];
- encodedStr = [encodedStr stringByReplacingOccurrencesOfString:@"&"
withString:@"%26"];
return encodedStr;
}
diff --git a/MediaWikiKit/MediaWikiKitTests/MWKDataStorePathTests.m
b/MediaWikiKit/MediaWikiKitTests/MWKDataStorePathTests.m
index 69b6561..751e845 100644
--- a/MediaWikiKit/MediaWikiKitTests/MWKDataStorePathTests.m
+++ b/MediaWikiKit/MediaWikiKitTests/MWKDataStorePathTests.m
@@ -69,11 +69,11 @@
}
- (void)testTitleUnicodePath {
- XCTAssertEqualObjects([dataStore pathForTitle:titleUnicode], [basePath
stringByAppendingPathComponent:@"sites/wikipedia.org/en/articles/%C3%89clair"]);
+ XCTAssertEqualObjects([dataStore pathForTitle:titleUnicode], [basePath
stringByAppendingPathComponent:@"sites/wikipedia.org/en/articles/Éclair"]);
}
- (void)testTitleEvilPath {
- XCTAssertEqualObjects([dataStore pathForTitle:titleEvil], [basePath
stringByAppendingPathComponent:@"sites/wikipedia.org/en/articles/AT%26T%2FSBC_%22merger%22"]);
+ XCTAssertEqualObjects([dataStore pathForTitle:titleEvil], [basePath
stringByAppendingPathComponent:@"sites/wikipedia.org/en/articles/AT&T%2FSBC_\"merger\""]);
}
- (void)testArticlePath {
--
To view, visit https://gerrit.wikimedia.org/r/183901
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I8e663ab8607352f51e6766bf2d31238299123a39
Gerrit-PatchSet: 1
Gerrit-Project: apps/ios/wikipedia
Gerrit-Branch: master
Gerrit-Owner: Brion VIBBER <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits