Commit 0a830ccc authored by Vasilii Sukhanov's avatar Vasilii Sukhanov Committed by Commit Bot

Fix a crash in TemplateURLParser.

It was caused by dereferencing an invalid URL during parsing.

Bug: 770734
Change-Id: I4fedd3f310aaf7e1e1d2384aa64939d46b8b2a5a
Reviewed-on: https://chromium-review.googlesource.com/773902
Commit-Queue: Vasilii Sukhanov <vasilii@chromium.org>
Reviewed-by: default avatarPeter Kasting <pkasting@chromium.org>
Cr-Commit-Position: refs/heads/master@{#517751}
parent 6812a72e
......@@ -245,3 +245,23 @@ TEST_F(TemplateURLParserTest, TestEmptyKeyword) {
template_url_->url());
EXPECT_EQ(ASCIIToUTF16("example.com"), template_url_->keyword());
}
// An invalid template URL should not crash the parser.
// crbug.com/770734
TEST_F(TemplateURLParserTest, InvalidInput) {
struct DumbFilter : TemplateURLParser::ParameterFilter {
bool KeepParameter(const std::string& key,
const std::string& value) override {
return true;
}
} filter;
constexpr char char_data[] = R"(
<OpenSearchDescription>
<Url template=")R:RRR?>RRR0" type="application/x-suggestions+json">
<Param name="name" value="value"/>
</Url>
</OpenSearchDescription>
)";
TemplateURLParser::Parse(SearchTermsData(), char_data, arraysize(char_data),
&filter);
}
......@@ -438,7 +438,7 @@ void TemplateURLParsingContext::ProcessURLParams() {
return;
GURL url(is_suggest_url_ ? data_.suggestions_url : data_.url());
if (url.is_empty())
if (!url.is_valid())
return;
// If there is a parameter filter, parse the existing URL and remove any
......
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