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

Side by Side Diff: net/http/http_util_unittest.cc

Issue 2225933004: Avoid adding invalid headers in AddHeaderFromString (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 4 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
« no previous file with comments | « net/http/http_util.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <algorithm> 5 #include <algorithm>
6 6
7 #include "base/strings/string_util.h" 7 #include "base/strings/string_util.h"
8 #include "net/http/http_util.h" 8 #include "net/http/http_util.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 10
(...skipping 1374 matching lines...) Expand 10 before | Expand all | Expand 10 after
1385 std::string allowed = "\t"; 1385 std::string allowed = "\t";
1386 for (char c = '\x20'; c < '\x7F'; ++c) { 1386 for (char c = '\x20'; c < '\x7F'; ++c) {
1387 allowed.append(1, c); 1387 allowed.append(1, c);
1388 } 1388 }
1389 for (int c = 0x80; c <= 0xFF; ++c) { 1389 for (int c = 0x80; c <= 0xFF; ++c) {
1390 allowed.append(1, static_cast<char>(c)); 1390 allowed.append(1, static_cast<char>(c));
1391 } 1391 }
1392 EXPECT_TRUE(HttpUtil::IsValidHeaderValue(allowed)); 1392 EXPECT_TRUE(HttpUtil::IsValidHeaderValue(allowed));
1393 } 1393 }
1394 1394
1395 TEST(HttpUtilTest, IsToken) {
1396 EXPECT_TRUE(HttpUtil::IsToken("valid"));
1397 EXPECT_FALSE(HttpUtil::IsToken(""));
1398 EXPECT_FALSE(HttpUtil::IsToken(base::StringPiece()));
1399 EXPECT_FALSE(HttpUtil::IsToken("hello, world"));
1400 }
1401
1395 } // namespace net 1402 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_util.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698