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

Side by Side Diff: Source/core/loader/LinkHeader.cpp

Issue 1322543003: Fix Link header parsing bug with extension parameter parsing. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Better comments Created 5 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
« no previous file with comments | « Source/core/loader/LinkHeader.h ('k') | Source/core/loader/LinkHeaderTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "config.h" 5 #include "config.h"
6 #include "core/loader/LinkHeader.h" 6 #include "core/loader/LinkHeader.h"
7 7
8 #include "platform/ParsingUtilities.h" 8 #include "platform/ParsingUtilities.h"
9 9
10 namespace blink { 10 namespace blink {
11 11
12 // LWSP definition in https://www.ietf.org/rfc/rfc0822.txt 12 // LWSP definition in https://www.ietf.org/rfc/rfc0822.txt
13 template <typename CharType> 13 template <typename CharType>
14 static bool isWhitespace(CharType chr) 14 static bool isWhitespace(CharType chr)
15 { 15 {
16 return (chr == ' ') || (chr == '\t'); 16 return (chr == ' ') || (chr == '\t');
17 } 17 }
18 18
19 template <typename CharType> 19 template <typename CharType>
20 static bool isValidURLChar(CharType chr) 20 static bool isValidURLChar(CharType chr)
21 { 21 {
22 return !isWhitespace(chr) && chr != '>'; 22 return !isWhitespace(chr) && chr != '>';
23 } 23 }
24 24
25 template <typename CharType> 25 template <typename CharType>
26 static bool isValidParameterNameChar(CharType chr) 26 static bool isValidParameterNameChar(CharType chr)
27 { 27 {
28 return !isWhitespace(chr) && chr != '='; 28 return !isWhitespace(chr) && chr != '=' && chr != ';' && chr != ',';
Nate Chapin 2015/08/27 21:39:16 Is there a spec for this?
29 } 29 }
30 30
31 template <typename CharType> 31 template <typename CharType>
32 static bool isValidParameterValueEnd(CharType chr) 32 static bool isValidParameterValueEnd(CharType chr)
33 { 33 {
34 return chr == ';' || chr == ','; 34 return chr == ';' || chr == ',';
35 } 35 }
36 36
37 template <typename CharType> 37 template <typename CharType>
38 static bool isValidParameterValueChar(CharType chr) 38 static bool isValidParameterValueChar(CharType chr)
39 { 39 {
40 return !isWhitespace(chr) && !isValidParameterValueEnd(chr); 40 return !isWhitespace(chr) && !isValidParameterValueEnd(chr);
41 } 41 }
42 42
43 // Verify that the parameter is a link-extension which according to spec doesn't have to have a value.
43 static bool isExtensionParameter(LinkHeader::LinkParameterName name) 44 static bool isExtensionParameter(LinkHeader::LinkParameterName name)
44 { 45 {
45 return name > LinkHeader::LinkParameterAnchor; 46 return name > LinkHeader::LinkParameterAnchor;
46 } 47 }
47 48
48 // Before: 49 // Before:
49 // 50 //
50 // <cat.jpg>; rel=preload 51 // <cat.jpg>; rel=preload
51 // ^ ^ 52 // ^ ^
52 // position end 53 // position end
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 template <typename CharType> 286 template <typename CharType>
286 void LinkHeaderSet::init(CharType* headerValue, unsigned len) 287 void LinkHeaderSet::init(CharType* headerValue, unsigned len)
287 { 288 {
288 CharType* position = headerValue; 289 CharType* position = headerValue;
289 CharType* end = headerValue + len; 290 CharType* end = headerValue + len;
290 while (position < end) 291 while (position < end)
291 m_headerSet.append(LinkHeader(position, end)); 292 m_headerSet.append(LinkHeader(position, end));
292 } 293 }
293 294
294 } 295 }
OLDNEW
« no previous file with comments | « Source/core/loader/LinkHeader.h ('k') | Source/core/loader/LinkHeaderTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698