Skip to content

Commit

Permalink
fix(ios): do not hard-crash on invalid string URLs (#13552)
Browse files Browse the repository at this point in the history
  • Loading branch information
hansemannn committed Sep 7, 2022
1 parent f0f73f6 commit 7dba199
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions iphone/Classes/TiUIImageView.m
Expand Up @@ -702,10 +702,13 @@ - (void)setImage_:(id)arg

if (image == nil) {
NSURL *imageURL = [[self proxy] sanitizeURL:arg];
// Try to fix the URL, e.g. if the encoding was missed
if ([imageURL isKindOfClass:[NSString class]]) {
imageURL = [[self proxy] sanitizeURL:[TiUtils encodeURIParameters:arg]];
}
if (![imageURL isKindOfClass:[NSURL class]]) {
[self throwException:@"invalid image type"
subreason:[NSString stringWithFormat:@"expected TiBlob, String, TiFile, was: %@", [arg class]]
location:CODELOCATION];
NSLog(@"[ERROR] Invalid image type: Expected TiBlob, String (qualified URL) or TiFile, was: %@", [arg class]);
return;
}

[self loadUrl:imageURL];
Expand Down

0 comments on commit 7dba199

Please sign in to comment.