Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(140)

Issue 2439953004: Remove invalid "suffix" assumption from CreateSortKey (Closed)

Created:
4 years, 2 months ago by vabr (Chromium)
Modified:
4 years, 1 month ago
Reviewers:
kolos1
CC:
chromium-reviews, gcasto+watchlist_chromium.org, vabr+watchlistpasswordmanager_chromium.org
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Remove invalid "suffix" assumption from CreateSortKey Currently, CreateSortKey in password_manager_presenter.cc assumes that domain and registry name obtained from a hostname string is always a suffix of the hostname string. This is true for ASCII-based examples like this: hostname: subdomain.example.com domain and registry: example.com But it is not true for non-ASCII-based examples like this: hostname: žřč.com domain and registry: xn--bea5m6d.com The reason is that to obtain the domain and registry, the hostname is being canonicalized. The domain and registry is used to create a sort key for a credential with the given hostname. The idea is to start with the domain and registry part, and then append the remaining subdomains (reversed). The remaining subdomains were computed by taking the prefix of hostname of the length of the difference of the length of the hostname minus the length of the domain and registry part. This number may overflow in case the domain and registry is not a suffix of the hostname. This CL fixes the issue by appending the whole hostname to the domain and registry part. The results look like this: hostname: subdomain.example.com old key: example.com.subdomain new key: example.com.com.example.subdomain hostname: žřč.com old key: undefined new key: xn--bea5m6d.com.com.žřč This is safe (no assumptions about suffixes) and preserves the sorting order of any two credentials before and after this change. It is potentially duplicating the domain and registry part. An alternative solution could just canonicalize the hostname before composing the key, but the code would be more complex for an unclear benefit. The CL also uses a more efficient call to GetDomainAndRegistry (avoiding redoing the canonicalization of a known URL). It also introduces a test and removes an unnecessary call to ASCIIToUTF16. BUG=655949 Committed: https://crrev.com/f77c3ffef00e68fe59150c78619dbdf289677400 Cr-Commit-Position: refs/heads/master@{#427051}

Patch Set 1 #

Patch Set 2 : Fix typo #

Total comments: 10

Patch Set 3 : Review comments #

Total comments: 2
Unified diffs Side-by-side diffs Delta from patch set Stats (+45 lines, -13 lines) Patch
M chrome/browser/ui/passwords/password_manager_presenter.cc View 1 2 2 chunks +7 lines, -10 lines 0 comments Download
M chrome/browser/ui/passwords/password_manager_presenter_unittest.cc View 1 2 4 chunks +38 lines, -3 lines 2 comments Download

Messages

Total messages: 22 (12 generated)
vabr (Chromium)
Hi Maxim, Please have a look. Cheers, Vaclav
4 years, 2 months ago (2016-10-21 20:22:43 UTC) #4
kolos1
Thanks Vaclav for checking and fixing this bug. LGTM % some comments. Please fix CL's ...
4 years, 2 months ago (2016-10-24 03:35:35 UTC) #7
vabr (Chromium)
Thanks, Maxim! I addressed your comments and will be sending to the CQ. Cheers, Vaclav ...
4 years, 2 months ago (2016-10-24 08:54:03 UTC) #9
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2439953004/40001
4 years, 2 months ago (2016-10-24 08:54:25 UTC) #12
commit-bot: I haz the power
Try jobs failed on following builders: linux_chromium_chromeos_rel_ng on master.tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/linux_chromium_chromeos_rel_ng/builds/301210)
4 years, 1 month ago (2016-10-24 10:47:37 UTC) #14
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2439953004/40001
4 years, 1 month ago (2016-10-24 10:49:35 UTC) #16
commit-bot: I haz the power
Committed patchset #3 (id:40001)
4 years, 1 month ago (2016-10-24 12:24:21 UTC) #18
commit-bot: I haz the power
Patchset 3 (id:??) landed as https://crrev.com/f77c3ffef00e68fe59150c78619dbdf289677400 Cr-Commit-Position: refs/heads/master@{#427051}
4 years, 1 month ago (2016-10-24 12:25:52 UTC) #20
kolos1
https://codereview.chromium.org/2439953004/diff/40001/chrome/browser/ui/passwords/password_manager_presenter_unittest.cc File chrome/browser/ui/passwords/password_manager_presenter_unittest.cc (right): https://codereview.chromium.org/2439953004/diff/40001/chrome/browser/ui/passwords/password_manager_presenter_unittest.cc#newcode323 chrome/browser/ui/passwords/password_manager_presenter_unittest.cc:323: LOG(INFO) << GURL("http://abč.com"); Hi Vaclav, Is it your intention ...
4 years, 1 month ago (2016-11-15 12:50:53 UTC) #21
vabr (Chromium)
4 years, 1 month ago (2016-11-15 17:55:20 UTC) #22
Message was sent while issue was closed.
https://codereview.chromium.org/2439953004/diff/40001/chrome/browser/ui/passw...
File chrome/browser/ui/passwords/password_manager_presenter_unittest.cc (right):

https://codereview.chromium.org/2439953004/diff/40001/chrome/browser/ui/passw...
chrome/browser/ui/passwords/password_manager_presenter_unittest.cc:323:
LOG(INFO) << GURL("http://abč.com");
On 2016/11/15 12:50:53, kolos1 wrote:
> Hi Vaclav,
> 
> Is it your intention to output these URLs? Or did you forget to remove them?
> 
> Regards,
> Maxim

Oops, definitely unintentional. Thanks for spotting it. I filed
https://codereview.chromium.org/2507493002 for removing them.

Powered by Google App Engine
This is Rietveld 408576698