]> git.saurik.com Git - cydia.git/commitdiff
Do not allow invalid APT config lines as sources.
authorJay Freeman (saurik) <saurik@saurik.com>
Wed, 14 May 2014 11:36:12 +0000 (04:36 -0700)
committerJay Freeman (saurik) <saurik@saurik.com>
Wed, 14 May 2014 11:36:12 +0000 (04:36 -0700)
MobileCydia.app/English.lproj/Localizable.strings
MobileCydia.mm

index fc3d5e4cdf49b2a2751eddb1da198e31164226db..a098861fb32da3df3848191acf42ed7ea13fb488 100644 (file)
@@ -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";
index e0539fa02988cdf99d4e73e3b9d3d02b14ec9b62..b8504f4b3b19ad119f3fcc8df7563df9d6f9caf1 100644 (file)
@@ -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<NSMutableArray> 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();