Skip to content

Commit

Permalink
[Android] Fix bug in address parser.
Browse files Browse the repository at this point in the history
Substring takes a length, not an index.

Bug:b/12125045

BUG=

Review URL: https://codereview.chromium.org/180873007

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@253956 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
benm@chromium.org committed Feb 27, 2014
1 parent 3489f76 commit fb3c8f4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ public void testFindAddress() {
assertNull(ContentViewStatics.findAddress("This is some random text"));

String googleAddr = "1600 Amphitheatre Pkwy, Mountain View, CA 94043";
assertEquals(googleAddr, ContentViewStatics.findAddress(googleAddr));
String testString = "Address: " + googleAddr + " in a string";
assertEquals(googleAddr, ContentViewStatics.findAddress(testString));
}

@SmallTest
Expand Down
3 changes: 2 additions & 1 deletion content/common/android/address_parser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ using namespace internal;
bool FindAddress(const base::string16& text, base::string16* address) {
size_t start, end;
if (FindAddress(text.begin(), text.end(), &start, &end)) {
address->assign(text.substr(start, end));
size_t len = end >= start ? end - start : 0;
address->assign(text.substr(start, len));
return true;
}
return false;
Expand Down

0 comments on commit fb3c8f4

Please sign in to comment.