diff --git a/GCDWebDAVServer/GCDWebDAVServer.h b/GCDWebDAVServer/GCDWebDAVServer.h index 89bf3d3..e2b31b0 100644 --- a/GCDWebDAVServer/GCDWebDAVServer.h +++ b/GCDWebDAVServer/GCDWebDAVServer.h @@ -102,7 +102,7 @@ * * The default value is NO. */ -@property(nonatomic) BOOL showHiddenFiles; +@property(nonatomic) BOOL allowHiddenItems; /** * This method is the designated initializer for the class. diff --git a/GCDWebDAVServer/GCDWebDAVServer.m b/GCDWebDAVServer/GCDWebDAVServer.m index 5a562c1..afbd86f 100644 --- a/GCDWebDAVServer/GCDWebDAVServer.m +++ b/GCDWebDAVServer/GCDWebDAVServer.m @@ -55,7 +55,7 @@ typedef NS_ENUM(NSInteger, DAVProperties) { @private NSString* _uploadDirectory; NSArray* _allowedExtensions; - BOOL _showHidden; + BOOL _allowHidden; } @end @@ -92,7 +92,7 @@ static inline BOOL _IsMacFinder(GCDWebServerRequest* request) { } NSString* itemName = [absolutePath lastPathComponent]; - if (([itemName hasPrefix:@"."] && !_showHidden) || (!isDirectory && ![self _checkFileExtension:itemName])) { + if (([itemName hasPrefix:@"."] && !_allowHidden) || (!isDirectory && ![self _checkFileExtension:itemName])) { return [GCDWebServerErrorResponse responseWithClientError:kGCDWebServerHTTPStatusCode_Forbidden message:@"Downlading item name \"%@\" is not allowed", itemName]; } @@ -130,7 +130,7 @@ static inline BOOL _IsMacFinder(GCDWebServerRequest* request) { } NSString* fileName = [absolutePath lastPathComponent]; - if (([fileName hasPrefix:@"."] && !_showHidden) || ![self _checkFileExtension:fileName]) { + if (([fileName hasPrefix:@"."] && !_allowHidden) || ![self _checkFileExtension:fileName]) { return [GCDWebServerErrorResponse responseWithClientError:kGCDWebServerHTTPStatusCode_Forbidden message:@"Uploading file name \"%@\" is not allowed", fileName]; } @@ -166,7 +166,7 @@ static inline BOOL _IsMacFinder(GCDWebServerRequest* request) { } NSString* itemName = [absolutePath lastPathComponent]; - if (([itemName hasPrefix:@"."] && !_showHidden) || (!isDirectory && ![self _checkFileExtension:itemName])) { + if (([itemName hasPrefix:@"."] && !_allowHidden) || (!isDirectory && ![self _checkFileExtension:itemName])) { return [GCDWebServerErrorResponse responseWithClientError:kGCDWebServerHTTPStatusCode_Forbidden message:@"Deleting item name \"%@\" is not allowed", itemName]; } @@ -203,7 +203,7 @@ static inline BOOL _IsMacFinder(GCDWebServerRequest* request) { } NSString* directoryName = [absolutePath lastPathComponent]; - if (!_showHidden && [directoryName hasPrefix:@"."]) { + if (!_allowHidden && [directoryName hasPrefix:@"."]) { return [GCDWebServerErrorResponse responseWithClientError:kGCDWebServerHTTPStatusCode_Forbidden message:@"Creating directory name \"%@\" is not allowed", directoryName]; } @@ -264,7 +264,7 @@ static inline BOOL _IsMacFinder(GCDWebServerRequest* request) { } NSString* itemName = [dstAbsolutePath lastPathComponent]; - if ((!_showHidden && [itemName hasPrefix:@"."]) || (!isDirectory && ![self _checkFileExtension:itemName])) { + if ((!_allowHidden && [itemName hasPrefix:@"."]) || (!isDirectory && ![self _checkFileExtension:itemName])) { return [GCDWebServerErrorResponse responseWithClientError:kGCDWebServerHTTPStatusCode_Forbidden message:@"%@ to item name \"%@\" is not allowed", isMove ? @"Moving" : @"Copying", itemName]; } @@ -430,7 +430,7 @@ static inline xmlNodePtr _XMLChildWithName(xmlNodePtr child, const xmlChar* name } NSString* itemName = [absolutePath lastPathComponent]; - if (([itemName hasPrefix:@"."] && !_showHidden) || (!isDirectory && ![self _checkFileExtension:itemName])) { + if (([itemName hasPrefix:@"."] && !_allowHidden) || (!isDirectory && ![self _checkFileExtension:itemName])) { return [GCDWebServerErrorResponse responseWithClientError:kGCDWebServerHTTPStatusCode_Forbidden message:@"Retrieving properties for item name \"%@\" is not allowed", itemName]; } @@ -454,7 +454,7 @@ static inline xmlNodePtr _XMLChildWithName(xmlNodePtr child, const xmlChar* name relativePath = [relativePath stringByAppendingString:@"/"]; } for (NSString* item in items) { - if (_showHidden || ![item hasPrefix:@"."]) { + if (_allowHidden || ![item hasPrefix:@"."]) { [self _addPropertyResponseForItem:[absolutePath stringByAppendingPathComponent:item] resource:[relativePath stringByAppendingString:item] properties:properties xmlString:xmlString]; } } @@ -525,7 +525,7 @@ static inline xmlNodePtr _XMLChildWithName(xmlNodePtr child, const xmlChar* name } NSString* itemName = [absolutePath lastPathComponent]; - if ((!_showHidden && [itemName hasPrefix:@"."]) || (!isDirectory && ![self _checkFileExtension:itemName])) { + if ((!_allowHidden && [itemName hasPrefix:@"."]) || (!isDirectory && ![self _checkFileExtension:itemName])) { return [GCDWebServerErrorResponse responseWithClientError:kGCDWebServerHTTPStatusCode_Forbidden message:@"Locking item name \"%@\" is not allowed", itemName]; } @@ -585,7 +585,7 @@ static inline xmlNodePtr _XMLChildWithName(xmlNodePtr child, const xmlChar* name } NSString* itemName = [absolutePath lastPathComponent]; - if ((!_showHidden && [itemName hasPrefix:@"."]) || (!isDirectory && ![self _checkFileExtension:itemName])) { + if ((!_allowHidden && [itemName hasPrefix:@"."]) || (!isDirectory && ![self _checkFileExtension:itemName])) { return [GCDWebServerErrorResponse responseWithClientError:kGCDWebServerHTTPStatusCode_Forbidden message:@"Unlocking item name \"%@\" is not allowed", itemName]; } @@ -597,7 +597,7 @@ static inline xmlNodePtr _XMLChildWithName(xmlNodePtr child, const xmlChar* name @implementation GCDWebDAVServer -@synthesize uploadDirectory=_uploadDirectory, allowedFileExtensions=_allowedExtensions, showHiddenFiles=_showHidden; +@synthesize uploadDirectory=_uploadDirectory, allowedFileExtensions=_allowedExtensions, allowHiddenItems=_allowHidden; - (instancetype)initWithUploadDirectory:(NSString*)path { if ((self = [super init])) { diff --git a/GCDWebUploader/GCDWebUploader.h b/GCDWebUploader/GCDWebUploader.h index 998f052..2a6e143 100644 --- a/GCDWebUploader/GCDWebUploader.h +++ b/GCDWebUploader/GCDWebUploader.h @@ -97,7 +97,7 @@ * * The default value is NO. */ -@property(nonatomic) BOOL showHiddenFiles; +@property(nonatomic) BOOL allowHiddenItems; /** * Sets the title for the uploader interface. diff --git a/GCDWebUploader/GCDWebUploader.m b/GCDWebUploader/GCDWebUploader.m index c2edd3b..c25e28e 100644 --- a/GCDWebUploader/GCDWebUploader.m +++ b/GCDWebUploader/GCDWebUploader.m @@ -46,7 +46,7 @@ @private NSString* _uploadDirectory; NSArray* _allowedExtensions; - BOOL _showHidden; + BOOL _allowHidden; NSString* _title; NSString* _header; NSString* _prologue; @@ -94,7 +94,7 @@ } NSString* directoryName = [absolutePath lastPathComponent]; - if (!_showHidden && [directoryName hasPrefix:@"."]) { + if (!_allowHidden && [directoryName hasPrefix:@"."]) { return [GCDWebServerErrorResponse responseWithClientError:kGCDWebServerHTTPStatusCode_Forbidden message:@"Listing directory name \"%@\" is not allowed", directoryName]; } @@ -106,7 +106,7 @@ NSMutableArray* array = [NSMutableArray array]; for (NSString* item in [contents sortedArrayUsingSelector:@selector(localizedStandardCompare:)]) { - if (_showHidden || ![item hasPrefix:@"."]) { + if (_allowHidden || ![item hasPrefix:@"."]) { NSDictionary* attributes = [[NSFileManager defaultManager] attributesOfItemAtPath:[absolutePath stringByAppendingPathComponent:item] error:NULL]; NSString* type = [attributes objectForKey:NSFileType]; if ([type isEqualToString:NSFileTypeRegular] && [self _checkFileExtension:item]) { @@ -138,7 +138,7 @@ } NSString* fileName = [absolutePath lastPathComponent]; - if (([fileName hasPrefix:@"."] && !_showHidden) || ![self _checkFileExtension:fileName]) { + if (([fileName hasPrefix:@"."] && !_allowHidden) || ![self _checkFileExtension:fileName]) { return [GCDWebServerErrorResponse responseWithClientError:kGCDWebServerHTTPStatusCode_Forbidden message:@"Downlading file name \"%@\" is not allowed", fileName]; } @@ -155,7 +155,7 @@ NSString* contentType = (range.location != NSNotFound ? @"application/json" : @"text/plain; charset=utf-8"); // Required when using iFrame transport (see https://github.com/blueimp/jQuery-File-Upload/wiki/Setup) GCDWebServerMultiPartFile* file = [request.files objectForKey:@"files[]"]; - if ((!_showHidden && [file.fileName hasPrefix:@"."]) || ![self _checkFileExtension:file.fileName]) { + if ((!_allowHidden && [file.fileName hasPrefix:@"."]) || ![self _checkFileExtension:file.fileName]) { return [GCDWebServerErrorResponse responseWithClientError:kGCDWebServerHTTPStatusCode_Forbidden message:@"Uploaded file name \"%@\" is not allowed", file.fileName]; } NSString* relativePath = [(GCDWebServerMultiPartArgument*)[request.arguments objectForKey:@"path"] string]; @@ -190,7 +190,7 @@ NSString* newAbsolutePath = [self _uniquePathForPath:[_uploadDirectory stringByAppendingPathComponent:newRelativePath]]; NSString* itemName = [newAbsolutePath lastPathComponent]; - if ((!_showHidden && [itemName hasPrefix:@"."]) || (!isDirectory && ![self _checkFileExtension:itemName])) { + if ((!_allowHidden && [itemName hasPrefix:@"."]) || (!isDirectory && ![self _checkFileExtension:itemName])) { return [GCDWebServerErrorResponse responseWithClientError:kGCDWebServerHTTPStatusCode_Forbidden message:@"Moving to item name \"%@\" is not allowed", itemName]; } @@ -220,7 +220,7 @@ } NSString* itemName = [absolutePath lastPathComponent]; - if (([itemName hasPrefix:@"."] && !_showHidden) || (!isDirectory && ![self _checkFileExtension:itemName])) { + if (([itemName hasPrefix:@"."] && !_allowHidden) || (!isDirectory && ![self _checkFileExtension:itemName])) { return [GCDWebServerErrorResponse responseWithClientError:kGCDWebServerHTTPStatusCode_Forbidden message:@"Deleting item name \"%@\" is not allowed", itemName]; } @@ -246,7 +246,7 @@ NSString* absolutePath = [self _uniquePathForPath:[_uploadDirectory stringByAppendingPathComponent:relativePath]]; NSString* directoryName = [absolutePath lastPathComponent]; - if (!_showHidden && [directoryName hasPrefix:@"."]) { + if (!_allowHidden && [directoryName hasPrefix:@"."]) { return [GCDWebServerErrorResponse responseWithClientError:kGCDWebServerHTTPStatusCode_Forbidden message:@"Creating directory name \"%@\" is not allowed", directoryName]; } @@ -271,7 +271,7 @@ @implementation GCDWebUploader -@synthesize uploadDirectory=_uploadDirectory, allowedFileExtensions=_allowedExtensions, showHiddenFiles=_showHidden, +@synthesize uploadDirectory=_uploadDirectory, allowedFileExtensions=_allowedExtensions, allowHiddenItems=_allowHidden, title=_title, header=_header, prologue=_prologue, epilogue=_epilogue, footer=_footer; - (instancetype)initWithUploadDirectory:(NSString*)path { diff --git a/iOS/AppDelegate.m b/iOS/AppDelegate.m index 2c61d1d..c3b21dc 100644 --- a/iOS/AppDelegate.m +++ b/iOS/AppDelegate.m @@ -57,7 +57,7 @@ NSString* documentsPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) firstObject]; _webServer = [[GCDWebUploader alloc] initWithUploadDirectory:documentsPath]; _webServer.delegate = self; - _webServer.showHiddenFiles = YES; + _webServer.allowHiddenItems = YES; [_webServer start]; return YES;