Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
nghttp2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
nghttp2
Commits
2e425e3c
Commit
2e425e3c
authored
Feb 09, 2015
by
Tatsuhiro Tsujikawa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
src: Support backslash escapes in quoted-string when parsing Link header
parent
1b00bc19
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
1 deletion
+30
-1
src/http2.cc
src/http2.cc
+23
-1
src/http2_test.cc
src/http2_test.cc
+7
-0
No files found.
src/http2.cc
View file @
2e425e3c
...
@@ -706,6 +706,28 @@ InputIt skip_to_next_field(InputIt first, InputIt last) {
...
@@ -706,6 +706,28 @@ InputIt skip_to_next_field(InputIt first, InputIt last) {
}
}
}
// namespace
}
// namespace
namespace
{
// Skip to the right dquote ('"'), handling backslash escapes.
// Returns |last| if input is not terminated with '"'.
template
<
typename
InputIt
>
InputIt
skip_to_right_dquote
(
InputIt
first
,
InputIt
last
)
{
for
(;
first
!=
last
;)
{
switch
(
*
first
)
{
case
'"'
:
return
first
;
case
'\\'
:
++
first
;
if
(
first
==
last
)
{
return
first
;
}
break
;
}
++
first
;
}
return
first
;
}
}
// namespace
namespace
{
namespace
{
std
::
pair
<
LinkHeader
,
const
char
*>
std
::
pair
<
LinkHeader
,
const
char
*>
parse_next_link_header_once
(
const
char
*
first
,
const
char
*
last
)
{
parse_next_link_header_once
(
const
char
*
first
,
const
char
*
last
)
{
...
@@ -862,7 +884,7 @@ parse_next_link_header_once(const char *first, const char *last) {
...
@@ -862,7 +884,7 @@ parse_next_link_header_once(const char *first, const char *last) {
}
}
if
(
*
first
==
'"'
)
{
if
(
*
first
==
'"'
)
{
// quoted-string
// quoted-string
first
=
s
td
::
find
(
first
+
1
,
last
,
'"'
);
first
=
s
kip_to_right_dquote
(
first
+
1
,
last
);
if
(
first
==
last
)
{
if
(
first
==
last
)
{
return
{{{
0
,
0
}},
first
};
return
{{{
0
,
0
}},
first
};
}
}
...
...
src/http2_test.cc
View file @
2e425e3c
...
@@ -593,6 +593,13 @@ void test_http2_parse_link_header(void) {
...
@@ -593,6 +593,13 @@ void test_http2_parse_link_header(void) {
auto
res
=
http2
::
parse_link_header
(
s
,
sizeof
(
s
)
-
1
);
auto
res
=
http2
::
parse_link_header
(
s
,
sizeof
(
s
)
-
1
);
CU_ASSERT
(
0
==
res
.
size
());
CU_ASSERT
(
0
==
res
.
size
());
}
}
{
// backslash escaped characters in quoted-string
const
char
s
[]
=
R"(<url>; rel=preload; title="foo\"baz\"bar")"
;
auto
res
=
http2
::
parse_link_header
(
s
,
sizeof
(
s
)
-
1
);
CU_ASSERT
(
1
==
res
.
size
());
CU_ASSERT
(
std
::
make_pair
(
&
s
[
1
],
&
s
[
4
])
==
res
[
0
].
uri
);
}
}
}
void
test_http2_path_join
(
void
)
{
void
test_http2_path_join
(
void
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment