Commit a163a67b authored by Dana Fried's avatar Dana Fried Committed by Commit Bot

Fix for potential security issue.

Changes two behaviors around hover cards:
 - overlong domains are now middle-elided, reducing the chance that bad
   data at either the beginning or end (depending on scheme) will
   mislead the user
 - blob: URLs now display as "temporary data" and no effort is made to
   display the "domain" of these URLs as it is not interesting at all to
   the user and only a source of potential exploitation

Bug: 1133183
Change-Id: I4779fa477a05e0017acffb2d9b98290939887f16
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2437154Reviewed-by: default avatarJoe DeBlasio <jdeblasio@chromium.org>
Commit-Queue: Dana Fried <dfried@chromium.org>
Cr-Commit-Position: refs/heads/master@{#812551}
parent 5d13c2e9
......@@ -399,6 +399,9 @@ are declared in tools/grit/grit_rule.gni.
<message name="IDS_HOVER_CARD_FILE_URL_SOURCE" desc="The text to be displayed in the source line of a hover card when viewing a local file.">
local or shared file
</message>
<message name="IDS_HOVER_CARD_BLOB_URL_SOURCE" desc="The text to be displayed in the source line of a hover card when viewing BLOB data.">
temporary data
</message>
<message name="IDS_HOVER_CARD_CRASHED_TITLE" desc="The title text to display on a hover card when a tab has crashed without loading.">
Crashed.
</message>
......
e36553696469777eaf228d129ddcfb38bac55ae6
\ No newline at end of file
......@@ -33,6 +33,7 @@
#include "ui/gfx/animation/tween.h"
#include "ui/gfx/image/image_skia.h"
#include "ui/gfx/paint_vector_icon.h"
#include "ui/gfx/text_constants.h"
#include "ui/native_theme/native_theme.h"
#include "ui/resources/grit/ui_resources.h"
#include "ui/views/animation/animation_delegate_views.h"
......@@ -451,7 +452,7 @@ TabHoverCardBubbleView::TabHoverCardBubbleView(Tab* tab)
base::string16(), views::style::CONTEXT_DIALOG_BODY_TEXT,
views::style::STYLE_SECONDARY,
gfx::DirectionalityMode::DIRECTIONALITY_AS_URL));
domain_label_->SetElideBehavior(gfx::ELIDE_HEAD);
domain_label_->SetElideBehavior(gfx::ELIDE_MIDDLE);
domain_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
domain_label_->SetMultiLine(false);
......@@ -459,7 +460,7 @@ TabHoverCardBubbleView::TabHoverCardBubbleView(Tab* tab)
base::string16(), views::style::CONTEXT_DIALOG_BODY_TEXT,
views::style::STYLE_SECONDARY,
gfx::DirectionalityMode::DIRECTIONALITY_AS_URL));
domain_fade_label_->SetElideBehavior(gfx::ELIDE_HEAD);
domain_fade_label_->SetElideBehavior(gfx::ELIDE_MIDDLE);
domain_fade_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
domain_fade_label_->SetMultiLine(false);
......@@ -745,13 +746,17 @@ void TabHoverCardBubbleView::UpdateCardContent(const Tab* tab) {
} else {
title_label_->SetElideBehavior(gfx::ELIDE_TAIL);
title_label_->SetMultiLine(true);
domain = url_formatter::FormatUrl(
domain_url,
url_formatter::kFormatUrlOmitDefaults |
url_formatter::kFormatUrlOmitHTTPS |
url_formatter::kFormatUrlOmitTrivialSubdomains |
url_formatter::kFormatUrlTrimAfterHost,
net::UnescapeRule::NORMAL, nullptr, nullptr, nullptr);
if (domain_url.SchemeIsBlob()) {
domain = l10n_util::GetStringUTF16(IDS_HOVER_CARD_BLOB_URL_SOURCE);
} else {
domain = url_formatter::FormatUrl(
domain_url,
url_formatter::kFormatUrlOmitDefaults |
url_formatter::kFormatUrlOmitHTTPS |
url_formatter::kFormatUrlOmitTrivialSubdomains |
url_formatter::kFormatUrlTrimAfterHost,
net::UnescapeRule::NORMAL, nullptr, nullptr, nullptr);
}
}
UpdateTextFade(0.0);
title_fade_label_->SetText(title_label_->GetText());
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment