Escape more characters in Mac OS sym-upload-v2 debug_file strings.
- Attempt to escape all characters which must be escaped in a URL or JSON string, for debug_file, since almost all of these are legal filename characters. Change-Id: Ic7a9c1aef00093d164683be7db84f4f282f45f7a Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/2339706 Reviewed-by: Mark Mentovai <mark@chromium.org>
This commit is contained in:
parent
e3a62dc550
commit
014e84252c
1 changed files with 29 additions and 8 deletions
|
@ -70,9 +70,16 @@
|
||||||
withAPIKey:(NSString*)APIKey
|
withAPIKey:(NSString*)APIKey
|
||||||
withDebugFile:(NSString*)debugFile
|
withDebugFile:(NSString*)debugFile
|
||||||
withDebugID:(NSString*)debugID {
|
withDebugID:(NSString*)debugID {
|
||||||
NSString* escapedDebugFile =
|
// Note that forward-slash is listed as a character to escape here, for
|
||||||
[debugFile stringByAddingPercentEncodingWithAllowedCharacters:
|
// completeness, however it is illegal in a debugFile input.
|
||||||
[NSCharacterSet URLHostAllowedCharacterSet]];
|
NSMutableCharacterSet* allowedDebugFileCharacters = [NSMutableCharacterSet
|
||||||
|
characterSetWithCharactersInString:@" \"\\/#%:?@|^`{}<>[]&=;"];
|
||||||
|
[allowedDebugFileCharacters
|
||||||
|
formUnionWithCharacterSet:[NSCharacterSet controlCharacterSet]];
|
||||||
|
[allowedDebugFileCharacters invert];
|
||||||
|
NSString* escapedDebugFile = [debugFile
|
||||||
|
stringByAddingPercentEncodingWithAllowedCharacters:
|
||||||
|
allowedDebugFileCharacters];
|
||||||
|
|
||||||
NSURL* URL = [NSURL
|
NSURL* URL = [NSURL
|
||||||
URLWithString:[NSString
|
URLWithString:[NSString
|
||||||
|
@ -187,17 +194,31 @@
|
||||||
URLWithString:[NSString
|
URLWithString:[NSString
|
||||||
stringWithFormat:@"%@/v1/uploads/%@:complete?key=%@",
|
stringWithFormat:@"%@/v1/uploads/%@:complete?key=%@",
|
||||||
APIURL, uploadKey, APIKey]];
|
APIURL, uploadKey, APIKey]];
|
||||||
NSString* body =
|
|
||||||
[NSString stringWithFormat:
|
NSDictionary* symbolIdDictionary =
|
||||||
@"{ symbol_id: { debug_file: \"%@\", debug_id: \"%@\" } }",
|
[NSDictionary dictionaryWithObjectsAndKeys:debugFile, @"debug_file",
|
||||||
debugFile, debugID];
|
debugID, @"debug_id", nil];
|
||||||
|
NSDictionary* jsonDictionary = [NSDictionary
|
||||||
|
dictionaryWithObjectsAndKeys:symbolIdDictionary, @"symbol_id", nil];
|
||||||
|
NSError* error;
|
||||||
|
NSData* jsonData =
|
||||||
|
[NSJSONSerialization dataWithJSONObject:jsonDictionary
|
||||||
|
options:NSJSONWritingPrettyPrinted
|
||||||
|
error:&error];
|
||||||
|
if (error) {
|
||||||
|
fprintf(stdout,
|
||||||
|
"Failed to complete upload. Could not write JSON payload.\n");
|
||||||
|
return CompleteUploadResultError;
|
||||||
|
}
|
||||||
|
NSString* body = [[NSString alloc] initWithData:jsonData
|
||||||
|
encoding:NSUTF8StringEncoding];
|
||||||
|
|
||||||
HTTPSimplePostRequest* postRequest =
|
HTTPSimplePostRequest* postRequest =
|
||||||
[[HTTPSimplePostRequest alloc] initWithURL:URL];
|
[[HTTPSimplePostRequest alloc] initWithURL:URL];
|
||||||
[postRequest setBody:body];
|
[postRequest setBody:body];
|
||||||
[postRequest setContentType:@"application/json"];
|
[postRequest setContentType:@"application/json"];
|
||||||
|
|
||||||
NSError* error = nil;
|
error = nil;
|
||||||
NSData* data = [postRequest send:&error];
|
NSData* data = [postRequest send:&error];
|
||||||
NSString* result = [[NSString alloc] initWithData:data
|
NSString* result = [[NSString alloc] initWithData:data
|
||||||
encoding:NSUTF8StringEncoding];
|
encoding:NSUTF8StringEncoding];
|
||||||
|
|
Loading…
Reference in a new issue