From 2595e4c379a0a75854a02dd9fc68dae99c274434 Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Wed, 14 May 2014 04:36:12 -0700 Subject: [PATCH] Do not allow invalid APT config lines as sources. --- .../English.lproj/Localizable.strings | 1 + MobileCydia.mm | 26 +++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/MobileCydia.app/English.lproj/Localizable.strings b/MobileCydia.app/English.lproj/Localizable.strings index fc3d5e4c..a098861f 100644 --- a/MobileCydia.app/English.lproj/Localizable.strings +++ b/MobileCydia.app/English.lproj/Localizable.strings @@ -94,6 +94,7 @@ "INSTALLED_BY_PACKAGE" = "Installed by Package"; "INSTALLED_DETAILS" = "Installed Package"; "INSTALLED_FILES" = "Installed Files"; +"INVALID_URL" = "Invalid URL"; "KEEP_OLD_COPY" = "Keep My Old Copy"; "LOADING" = "Loading"; "LOADING_DATA" = "Loading Data"; diff --git a/MobileCydia.mm b/MobileCydia.mm index e0539fa0..b8504f4b 100644 --- a/MobileCydia.mm +++ b/MobileCydia.mm @@ -8454,6 +8454,22 @@ static void HomeControllerReachabilityCallback(SCNetworkReachabilityRef reachabi case 1: { NSString *href = [[alert textField] text]; + static Pcre href_r("^http(s?)://[^# ]*$"); + if (!href_r(href)) { + UIAlertView *alert = [[[UIAlertView alloc] + initWithTitle:Error_ + message:UCLocalize("INVALID_URL") + delegate:self + cancelButtonTitle:UCLocalize("OK") + otherButtonTitles:nil + ] autorelease]; + + [alert setContext:@"badurl"]; + [alert show]; + + break; + } + if (![href hasSuffix:@"/"]) href_ = [href stringByAppendingString:@"/"]; else @@ -10213,6 +10229,16 @@ int main(int argc, char *argv[]) { Changed_ = true; } + + _H broken([NSMutableArray array]); + for (NSString *key in (id) Sources_) + if ([key rangeOfCharacterFromSet:[NSCharacterSet characterSetWithCharactersInString:@"# "]].location != NSNotFound) + [broken addObject:key]; + if ([broken count] != 0) { + for (NSString *key in (id) broken) + [Sources_ removeObjectForKey:key]; + Changed_ = true; + } broken = nil; /* }}} */ CydiaWriteSources(); -- 2.45.2