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

Unified Diff: src/url_canon_unittest.cc

Issue 2027007: Fix a crash in IP address checking because the boundary case for an empty or ... (Closed) Base URL: http://google-url.googlecode.com/svn/trunk/
Patch Set: Created 10 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« src/url_canon_ip.cc ('K') | « src/url_canon_ip.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/url_canon_unittest.cc
===================================================================
--- src/url_canon_unittest.cc (revision 133)
+++ src/url_canon_unittest.cc (working copy)
@@ -761,11 +761,27 @@
if (host_info.family == CanonHostInfo::IPV6) {
EXPECT_STREQ(cases[i].expected, out_str2.c_str());
EXPECT_EQ(cases[i].expected_component.begin, host_info.out_host.begin);
- EXPECT_EQ(cases[i].expected_component.len, host_info.out_host.len);
+ EXPECT_EQ(cases[i].expected_compo nent.len, host_info.out_host.len);
}
}
}
+TEST(URLCanonTest, IPEmpty) {
+ std::string out_str1;
+ url_canon::StdStringCanonOutput output1(&out_str1);
+ url_canon::CanonHostInfo host_info;
+
+ // This tests tests.
+ const char spec[] = "192.168.0.1";
+ url_canon::CanonicalizeIPAddress(spec, url_parse::Component(),
+ &output1, &host_info);
+ EXPECT_FALSE(host_info.IsIPAddress());
+
+ url_canon::CanonicalizeIPAddress(spec, url_parse::Component(0, 0),
+ &output1, &host_info);
+ EXPECT_FALSE(host_info.IsIPAddress());
+}
+
TEST(URLCanonTest, UserInfo) {
// Note that the canonicalizer should escape and treat empty components as
// not being there.
« src/url_canon_ip.cc ('K') | « src/url_canon_ip.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698