Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
Actor Framework
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
Operations
Operations
Metrics
Environments
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
cpp-libs
Actor Framework
Commits
de9ae8ca
Commit
de9ae8ca
authored
Jul 10, 2018
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Accept percent-encoding in query component
parent
c448f565
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
18 deletions
+19
-18
libcaf_core/caf/detail/parser/read_uri.hpp
libcaf_core/caf/detail/parser/read_uri.hpp
+19
-18
No files found.
libcaf_core/caf/detail/parser/read_uri.hpp
View file @
de9ae8ca
...
@@ -67,6 +67,14 @@ void read_uri_percent_encoded(state<Iterator, Sentinel>& ps, std::string& str) {
...
@@ -67,6 +67,14 @@ void read_uri_percent_encoded(state<Iterator, Sentinel>& ps, std::string& str) {
fin
();
fin
();
}
}
inline
bool
uri_unprotected_char
(
char
c
)
{
return
in_whitelist
(
alphanumeric_chars
,
c
)
||
in_whitelist
(
"-._~"
,
c
);
}
#define read_next_char(next_state, dest) \
transition(next_state, uri_unprotected_char, dest += ch) \
fsm_transition(read_uri_percent_encoded(ps, dest), next_state, '%')
template
<
class
Iterator
,
class
Sentinel
,
class
Consumer
>
template
<
class
Iterator
,
class
Sentinel
,
class
Consumer
>
void
read_uri_query
(
state
<
Iterator
,
Sentinel
>&
ps
,
Consumer
&&
consumer
)
{
void
read_uri_query
(
state
<
Iterator
,
Sentinel
>&
ps
,
Consumer
&&
consumer
)
{
// Local variables.
// Local variables.
...
@@ -92,23 +100,19 @@ void read_uri_query(state<Iterator, Sentinel>& ps, Consumer&& consumer) {
...
@@ -92,23 +100,19 @@ void read_uri_query(state<Iterator, Sentinel>& ps, Consumer&& consumer) {
start
();
start
();
// query may be empty
// query may be empty
term_state
(
init
)
{
term_state
(
init
)
{
transition
(
read_key
,
alphabetic_chars
,
key
+=
ch
)
read_next_char
(
read_key
,
key
)
}
}
state
(
read_key
)
{
state
(
read_key
)
{
transition
(
read_key
,
alphanumeric_chars
,
key
+=
ch
)
read_next_char
(
read_key
,
key
)
transition
(
read_value
,
'='
)
transition
(
read_value
,
'='
)
}
}
term_state
(
read_value
,
push
())
{
term_state
(
read_value
,
push
())
{
transition
(
read_value
,
alphanumeric_chars
,
value
+=
ch
)
read_next_char
(
read_value
,
value
)
transition
(
read_key
,
'&'
,
push
())
transition
(
init
,
'&'
,
push
())
}
}
fin
();
fin
();
}
}
#define read_next_char(next_state) \
transition(next_state, unprotected_char, str += ch) \
fsm_transition(read_uri_percent_encoded(ps, str), next_state, '%')
template
<
class
Iterator
,
class
Sentinel
,
class
Consumer
>
template
<
class
Iterator
,
class
Sentinel
,
class
Consumer
>
void
read_uri
(
state
<
Iterator
,
Sentinel
>&
ps
,
Consumer
&&
consumer
)
{
void
read_uri
(
state
<
Iterator
,
Sentinel
>&
ps
,
Consumer
&&
consumer
)
{
// Local variables.
// Local variables.
...
@@ -126,9 +130,6 @@ void read_uri(state<Iterator, Sentinel>& ps, Consumer&& consumer) {
...
@@ -126,9 +130,6 @@ void read_uri(state<Iterator, Sentinel>& ps, Consumer&& consumer) {
auto
path_char
=
[](
char
c
)
{
auto
path_char
=
[](
char
c
)
{
return
in_whitelist
(
alphanumeric_chars
,
c
)
||
c
==
'/'
;
return
in_whitelist
(
alphanumeric_chars
,
c
)
||
c
==
'/'
;
};
};
auto
unprotected_char
=
[](
char
c
)
{
return
in_whitelist
(
alphanumeric_chars
,
c
)
||
in_whitelist
(
"-._~"
,
c
);
};
// Utility setters for avoiding code duplication.
// Utility setters for avoiding code duplication.
auto
set_path
=
[
&
]
{
auto
set_path
=
[
&
]
{
consumer
.
path
(
take_str
());
consumer
.
path
(
take_str
());
...
@@ -152,12 +153,12 @@ void read_uri(state<Iterator, Sentinel>& ps, Consumer&& consumer) {
...
@@ -152,12 +153,12 @@ void read_uri(state<Iterator, Sentinel>& ps, Consumer&& consumer) {
epsilon
(
read_scheme
)
epsilon
(
read_scheme
)
}
}
state
(
read_scheme
)
{
state
(
read_scheme
)
{
read_next_char
(
read_scheme
)
read_next_char
(
read_scheme
,
str
)
transition
(
have_scheme
,
':'
,
consumer
.
scheme
(
take_str
()))
transition
(
have_scheme
,
':'
,
consumer
.
scheme
(
take_str
()))
}
}
state
(
have_scheme
)
{
state
(
have_scheme
)
{
transition
(
disambiguate_path
,
'/'
)
transition
(
disambiguate_path
,
'/'
)
read_next_char
(
read_path
)
read_next_char
(
read_path
,
str
)
fsm_transition
(
read_uri_percent_encoded
(
ps
,
str
),
read_path
,
'%'
)
fsm_transition
(
read_uri_percent_encoded
(
ps
,
str
),
read_path
,
'%'
)
}
}
// This state is terminal, because "file:/" is a valid URI.
// This state is terminal, because "file:/" is a valid URI.
...
@@ -166,7 +167,7 @@ void read_uri(state<Iterator, Sentinel>& ps, Consumer&& consumer) {
...
@@ -166,7 +167,7 @@ void read_uri(state<Iterator, Sentinel>& ps, Consumer&& consumer) {
epsilon
(
read_path
,
any_char
,
str
+=
'/'
)
epsilon
(
read_path
,
any_char
,
str
+=
'/'
)
}
}
state
(
start_authority
)
{
state
(
start_authority
)
{
read_next_char
(
read_authority
)
read_next_char
(
read_authority
,
str
)
fsm_transition
(
read_ipv6_address
(
ps
,
ip_consumer
),
await_end_of_ipv6
,
'['
)
fsm_transition
(
read_ipv6_address
(
ps
,
ip_consumer
),
await_end_of_ipv6
,
'['
)
}
}
state
(
await_end_of_ipv6
)
{
state
(
await_end_of_ipv6
)
{
...
@@ -181,17 +182,17 @@ void read_uri(state<Iterator, Sentinel>& ps, Consumer&& consumer) {
...
@@ -181,17 +182,17 @@ void read_uri(state<Iterator, Sentinel>& ps, Consumer&& consumer) {
epsilon
(
end_of_authority
,
"/?#"
,
set_host
())
epsilon
(
end_of_authority
,
"/?#"
,
set_host
())
}
}
term_state
(
read_authority
,
set_host
())
{
term_state
(
read_authority
,
set_host
())
{
read_next_char
(
read_authority
)
read_next_char
(
read_authority
,
str
)
transition
(
start_host
,
'@'
,
set_userinfo
())
transition
(
start_host
,
'@'
,
set_userinfo
())
transition
(
start_port
,
':'
,
set_host
())
transition
(
start_port
,
':'
,
set_host
())
epsilon
(
end_of_authority
,
"/?#"
,
set_host
())
epsilon
(
end_of_authority
,
"/?#"
,
set_host
())
}
}
state
(
start_host
)
{
state
(
start_host
)
{
read_next_char
(
read_host
)
read_next_char
(
read_host
,
str
)
fsm_transition
(
read_ipv6_address
(
ps
,
ip_consumer
),
await_end_of_ipv6
,
'['
)
fsm_transition
(
read_ipv6_address
(
ps
,
ip_consumer
),
await_end_of_ipv6
,
'['
)
}
}
term_state
(
read_host
,
set_host
())
{
term_state
(
read_host
,
set_host
())
{
read_next_char
(
read_host
)
read_next_char
(
read_host
,
str
)
transition
(
start_port
,
':'
,
set_host
())
transition
(
start_port
,
':'
,
set_host
())
epsilon
(
end_of_authority
,
"/?#"
,
set_host
())
epsilon
(
end_of_authority
,
"/?#"
,
set_host
())
}
}
...
@@ -222,7 +223,7 @@ void read_uri(state<Iterator, Sentinel>& ps, Consumer&& consumer) {
...
@@ -222,7 +223,7 @@ void read_uri(state<Iterator, Sentinel>& ps, Consumer&& consumer) {
epsilon
(
done
)
epsilon
(
done
)
}
}
term_state
(
read_fragment
,
consumer
.
fragment
(
take_str
()))
{
term_state
(
read_fragment
,
consumer
.
fragment
(
take_str
()))
{
read_next_char
(
read_fragment
)
read_next_char
(
read_fragment
,
str
)
}
}
term_state
(
done
)
{
term_state
(
done
)
{
// nop
// nop
...
...
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