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

Side by Side Diff: net/base/data_url_unittest.cc

Issue 555383003: [Regression fix] [Data URI parser] Accept data URI with invalid mediatype data (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed InvalidMimeType unittest Created 6 years, 3 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/basictypes.h" 5 #include "base/basictypes.h"
6 #include "net/base/data_url.h" 6 #include "net/base/data_url.h"
7 #include "testing/gtest/include/gtest/gtest.h" 7 #include "testing/gtest/include/gtest/gtest.h"
8 #include "url/gurl.h" 8 #include "url/gurl.h"
9 9
10 namespace { 10 namespace {
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 "text/plain", 56 "text/plain",
57 "US-ASCII", 57 "US-ASCII",
58 "foo" }, 58 "foo" },
59 59
60 { "data:;base64,aGVsbG8gd29ybGQ=", 60 { "data:;base64,aGVsbG8gd29ybGQ=",
61 true, 61 true,
62 "text/plain", 62 "text/plain",
63 "US-ASCII", 63 "US-ASCII",
64 "hello world" }, 64 "hello world" },
65 65
66 // Allow token mediatype for backward compatibility
67 { "data:foo,boo",
68 true,
69 "foo",
70 "US-ASCII",
71 "boo" },
72
66 { "data:foo/bar;baz=1;charset=kk,boo", 73 { "data:foo/bar;baz=1;charset=kk,boo",
67 true, 74 true,
68 "foo/bar", 75 "foo/bar",
69 "kk", 76 "kk",
70 "boo" }, 77 "boo" },
71 78
72 { "data:foo/bar;charset=kk;baz=1,boo", 79 { "data:foo/bar;charset=kk;baz=1,boo",
73 true, 80 true,
74 "foo/bar", 81 "foo/bar",
75 "kk", 82 "kk",
76 "boo" }, 83 "boo" },
77 84
78 { "data:text/html,%3Chtml%3E%3Cbody%3E%3Cb%3Ehello%20world" 85 { "data:text/html,%3Chtml%3E%3Cbody%3E%3Cb%3Ehello%20world"
79 "%3C%2Fb%3E%3C%2Fbody%3E%3C%2Fhtml%3E", 86 "%3C%2Fb%3E%3C%2Fbody%3E%3C%2Fhtml%3E",
80 true, 87 true,
81 "text/html", 88 "text/html",
82 "US-ASCII", 89 "US-ASCII",
83 "<html><body><b>hello world</b></body></html>" }, 90 "<html><body><b>hello world</b></body></html>" },
84 91
85 { "data:text/html,<html><body><b>hello world</b></body></html>", 92 { "data:text/html,<html><body><b>hello world</b></body></html>",
86 true, 93 true,
87 "text/html", 94 "text/html",
88 "US-ASCII", 95 "US-ASCII",
89 "<html><body><b>hello world</b></body></html>" }, 96 "<html><body><b>hello world</b></body></html>" },
90 97
91 // Bad mime type 98 // Bad mime type
92 { "data:f(oo/bar;baz=1;charset=kk,boo", 99 { "data:f(oo/bar;baz=1;charset=kk,boo",
93 false, 100 true,
94 "", 101 "f(oo/bar",
95 "", 102 "kk",
96 "" }, 103 "boo" },
97 104
98 // the comma cannot be url-escaped! 105 // the comma cannot be url-escaped!
99 { "data:%2Cblah", 106 { "data:%2Cblah",
100 false, 107 false,
101 "", 108 "",
102 "", 109 "",
103 "" }, 110 "" },
104 111
105 // invalid base64 content 112 // invalid base64 content
106 { "data:;base64,aGVs_-_-", 113 { "data:;base64,aGVs_-_-",
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 bool ok = 186 bool ok =
180 net::DataURL::Parse(GURL(tests[i].url), &mime_type, &charset, &data); 187 net::DataURL::Parse(GURL(tests[i].url), &mime_type, &charset, &data);
181 EXPECT_EQ(ok, tests[i].is_valid); 188 EXPECT_EQ(ok, tests[i].is_valid);
182 if (tests[i].is_valid) { 189 if (tests[i].is_valid) {
183 EXPECT_EQ(tests[i].mime_type, mime_type); 190 EXPECT_EQ(tests[i].mime_type, mime_type);
184 EXPECT_EQ(tests[i].charset, charset); 191 EXPECT_EQ(tests[i].charset, charset);
185 EXPECT_EQ(tests[i].data, data); 192 EXPECT_EQ(tests[i].data, data);
186 } 193 }
187 } 194 }
188 } 195 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698