Skip to content

Commit

Permalink
Add URL validation for network streams
Browse files Browse the repository at this point in the history
  • Loading branch information
dnicolson authored and fkuehne committed Jun 20, 2022
1 parent a1ef05d commit b7bf94f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
4 changes: 3 additions & 1 deletion Apple-TV/VLCOpenNetworkStreamTVViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,9 @@ - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
- (void)URLEnteredInField:(id)sender
{
NSString *urlString = self.playURLField.text;
if (urlString.length) {
NSURL *url = [NSURL URLWithString:urlString];

if (url && url.scheme && url.host) {
if ([_recentURLs indexOfObject:urlString] != NSNotFound)
[_recentURLs removeObject:urlString];

Expand Down
26 changes: 15 additions & 11 deletions Sources/VLCOpenNetworkStreamViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -252,19 +252,23 @@ - (IBAction)openButtonAction:(id)sender
}
if (!self.privateToggleButton.selected) {
NSString *urlString = self.urlField.text;
if ([_recentURLs indexOfObject:urlString] != NSNotFound)
[_recentURLs removeObject:urlString];
NSURL *url = [NSURL URLWithString:urlString];

if (url && url.scheme && url.host) {
if ([_recentURLs indexOfObject:urlString] != NSNotFound)
[_recentURLs removeObject:urlString];

if (_recentURLs.count >= 100)
[_recentURLs removeLastObject];
[_recentURLs addObject:urlString];
if ([self ubiquitousKeyStoreAvailable]) {
[[NSUbiquitousKeyValueStore defaultStore] setArray:_recentURLs forKey:kVLCRecentURLs];
} else {
[[NSUserDefaults standardUserDefaults] setObject:_recentURLs forKey:kVLCRecentURLs];
}

if (_recentURLs.count >= 100)
[_recentURLs removeLastObject];
[_recentURLs addObject:urlString];
if ([self ubiquitousKeyStoreAvailable]) {
[[NSUbiquitousKeyValueStore defaultStore] setArray:_recentURLs forKey:kVLCRecentURLs];
} else {
[[NSUserDefaults standardUserDefaults] setObject:_recentURLs forKey:kVLCRecentURLs];
[self.historyTableView reloadData];
}

[self.historyTableView reloadData];
}
[self.urlField resignFirstResponder];
[self _openURLStringAndDismiss:self.urlField.text];
Expand Down

0 comments on commit b7bf94f

Please sign in to comment.