Commit 9a21057f authored by Felix Paul Kühne's avatar Felix Paul Kühne

app delegate: fix major leak of data transmitted by 3rd party apps (close #9011)

The input folder was never emptied and therefore stacking up every media opened from within another app. The implemented solution moves received data directly to Documents without asking the user if s/he would like to save it or not. This matches iBooks behavior and many other apps
parent 69b623d9
......@@ -20,7 +20,6 @@
#import "UINavigationController+Theme.h"
@interface VLCAppDelegate () <PAPasscodeViewControllerDelegate, DirectoryWatcherDelegate> {
NSURL *_tempURL;
PAPasscodeViewController *_passcodeLockController;
VLCDropboxTableViewController *_dropboxTableViewController;
......@@ -81,9 +80,15 @@
APLog(@"%@ requested %@ to be opened", sourceApplication, url);
if (url.isFileURL) {
UIAlertView * alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"SAVE_FILE", @"") message:[NSString stringWithFormat:NSLocalizedString(@"SAVE_FILE_LONG", @""), url.lastPathComponent] delegate:self cancelButtonTitle:NSLocalizedString(@"BUTTON_CANCEL", @"") otherButtonTitles:NSLocalizedString(@"BUTTON_SAVE", @""), nil];
_tempURL = url;
[alert show];
NSArray *searchPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *directoryPath = searchPaths[0];
NSURL *destinationURL = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/%@", directoryPath, url.lastPathComponent]];
NSError *theError;
[[NSFileManager defaultManager] moveItemAtURL:url toURL:destinationURL error:&theError];
if (theError.code != noErr)
APLog(@"saving the file failed (%i): %@", theError.code, theError.localizedDescription);
[self updateMediaList];
} else {
NSURL *parsedUrl = [self parseOpenURL:url];
[_playlistViewController openMovieFromURL:parsedUrl];
......@@ -120,22 +125,6 @@
return url;
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if (buttonIndex == 1) {
NSArray *searchPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *directoryPath = searchPaths[0];
NSURL *destinationURL = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/%@", directoryPath, _tempURL.lastPathComponent]];
NSError *theError;
[[NSFileManager defaultManager] copyItemAtURL:_tempURL toURL:destinationURL error:&theError];
if (theError.code != noErr)
APLog(@"saving the file failed (%i): %@", theError.code, theError.localizedDescription);
[self updateMediaList];
} else
[_playlistViewController openMovieFromURL:_tempURL];
}
- (void)applicationWillResignActive:(UIApplication *)application
{
[[MLMediaLibrary sharedMediaLibrary] applicationWillExit];
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment