Skip to content

Commit

Permalink
Cast find_in_page.js return value from id to NSString.
Browse files Browse the repository at this point in the history
Currently JsFindinpageManager passes the result of find_in_page.js to
base::SysNSStringToUTF8 with "id" type. This CL casts it to NSString
to prevent it from crashing the APP when the result is not NSString.

Bug: 924441
Change-Id: Ib02e80c09ef8c3af9f877f0c70cf1361fc019dd5
Reviewed-on: https://chromium-review.googlesource.com/c/1433754
Commit-Queue: Yi Su <[email protected]>
Reviewed-by: Mike Dougherty <[email protected]>
Cr-Original-Commit-Position: refs/heads/master@{#626028}(cherry picked from commit 831dfd6)
Reviewed-on: https://chromium-review.googlesource.com/c/1445038
Reviewed-by: Yi Su <[email protected]>
Cr-Commit-Position: refs/branch-heads/3683@{#61}
Cr-Branched-From: e510299-refs/heads/master@{#625896}
  • Loading branch information
Yi Su committed Jan 30, 2019
1 parent ac16eeb commit 4b50559
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions ios/chrome/browser/find_in_page/js_findinpage_manager.mm
Original file line number Diff line number Diff line change
Expand Up @@ -169,11 +169,12 @@ - (void)disableWithCompletionHandler:(ProceduralBlock)completionHandler {
#pragma mark FindInPageEntry

- (BOOL)processFindInPageResult:(id)result scrollPosition:(CGPoint*)point {
if (!result)
NSString* result_str = base::mac::ObjCCastStrict<NSString>(result);
if (!result_str)
return NO;

// Parse JSONs.
std::string json = base::SysNSStringToUTF8(result);
std::string json = base::SysNSStringToUTF8(result_str);
std::unique_ptr<base::Value> root(base::JSONReader::Read(json, false));
if (!root.get())
return YES;
Expand Down

0 comments on commit 4b50559

Please sign in to comment.