Skip to content
This repository was archived by the owner on Apr 25, 2019. It is now read-only.

Prevent objects that are already percent encoded from being double encoded #126

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions FPPicker/Shared/FPLibrary.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@
andMimetypes:(NSArray *)mimetypes
cachePolicy:(NSURLRequestCachePolicy)policy;

+ (NSURLRequest *)requestForLoadPath:(NSString *)loadpath
withFormat:(NSString *)type
queryString:(NSString *)queryString
andMimetypes:(NSArray *)mimetypes
cachePolicy:(NSURLRequestCachePolicy)policy
shouldURLEncode:(BOOL)encode;

#ifdef FPLibrary_protected

+ (void)uploadLocalURLToFilepicker:(NSURL *)localURL
Expand Down
27 changes: 25 additions & 2 deletions FPPicker/Shared/FPLibrary.m
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ + (void)requestObjectMediaInfo:(NSDictionary *)obj
withFormat:@"data"
queryString:nil
andMimetypes:source.mimetypes
cachePolicy:NSURLRequestReloadRevalidatingCacheData];
cachePolicy:NSURLRequestReloadRevalidatingCacheData
shouldURLEncode:NO];

NSString *tempPath = [NSTemporaryDirectory() stringByAppendingPathComponent:[FPUtils genRandStringLength:20]];

Expand Down Expand Up @@ -281,6 +282,21 @@ + (NSURLRequest *)requestForLoadPath:(NSString *)loadpath
queryString:(NSString *)queryString
andMimetypes:(NSArray *)mimetypes
cachePolicy:(NSURLRequestCachePolicy)policy
{
return [self requestForLoadPath:loadpath
withFormat:type
queryString:queryString
andMimetypes:mimetypes
cachePolicy:policy
shouldURLEncode:YES];
}

+ (NSURLRequest *)requestForLoadPath:(NSString *)loadpath
withFormat:(NSString *)type
queryString:(NSString *)queryString
andMimetypes:(NSArray *)mimetypes
cachePolicy:(NSURLRequestCachePolicy)policy
shouldURLEncode:(BOOL)encode;
{
FPSession *fpSession = [FPSession sessionForFileUploads];
fpSession.mimetypes = mimetypes;
Expand All @@ -289,7 +305,14 @@ + (NSURLRequest *)requestForLoadPath:(NSString *)loadpath
NSURLComponents *urlComponents = [NSURLComponents componentsWithString:fpBASE_URL];

urlComponents.query = queryString;
urlComponents.path = [NSString stringWithFormat:@"/api/path%@", loadpath];
if (encode)
{
urlComponents.path = [NSString stringWithFormat:@"/api/path%@", loadpath];
}
else
{
urlComponents.percentEncodedPath = [NSString stringWithFormat:@"/api/path%@", loadpath];
}

NSArray *queryItems = @[
[NSURLQueryItem queryItemWithName:@"format" value:type],
Expand Down