diff options
author | Jorge Canizales <jcanizales@google.com> | 2015-09-02 23:05:53 -0700 |
---|---|---|
committer | Jorge Canizales <jcanizales@google.com> | 2015-09-02 23:05:53 -0700 |
commit | bbba491b7cbf75104d1efcc72653a8498a935f17 (patch) | |
tree | 120d5f1649ddd0a3870b805036cf75a3def2c623 /src/objective-c/GRPCClient/private | |
parent | 2529735d3d2c9124484b4c242e29e2fe8e0f938c (diff) |
Reject non-ASCII text header values too.
Diffstat (limited to 'src/objective-c/GRPCClient/private')
-rw-r--r-- | src/objective-c/GRPCClient/private/GRPCRequestHeaders.m | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/objective-c/GRPCClient/private/GRPCRequestHeaders.m b/src/objective-c/GRPCClient/private/GRPCRequestHeaders.m index 310f1655e4..dfec2a7e7e 100644 --- a/src/objective-c/GRPCClient/private/GRPCRequestHeaders.m +++ b/src/objective-c/GRPCClient/private/GRPCRequestHeaders.m @@ -39,13 +39,13 @@ #import "NSDictionary+GRPC.h" // Used by the setter. -static void CheckKeyIsValid(NSString* key) { - if (!key) { - [NSException raise:NSInvalidArgumentException format:@"Key cannot be nil"]; +static void CheckIsNonNilASCII(NSString *name, NSString* value) { + if (!value) { + [NSException raise:NSInvalidArgumentException format:@"%@ cannot be nil", name]; } - if (![key canBeConvertedToEncoding:NSASCIIStringEncoding]) { + if (![value canBeConvertedToEncoding:NSASCIIStringEncoding]) { [NSException raise:NSInvalidArgumentException - format:@"Key %@ contains non-ASCII characters", key]; + format:@"%@ %@ contains non-ASCII characters", name, value]; } } @@ -63,6 +63,7 @@ static void CheckKeyValuePairIsValid(NSString *key, id value) { format:@"Expected NSString value for header %@ not ending in \"-bin\", " @"instead got %@", key, value]; } + CheckIsNonNilASCII(@"Text header value", (NSString *)value); } } @@ -92,7 +93,7 @@ static void CheckKeyValuePairIsValid(NSString *key, id value) { - (void)setObject:(id)obj forKeyedSubscript:(NSString *)key { [self checkCallIsNotStarted]; - CheckKeyIsValid(key); + CheckIsNonNilASCII(@"Header name", key); key = key.lowercaseString; CheckKeyValuePairIsValid(key, obj); _delegate[key] = obj; |