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
bf152e63
Commit
bf152e63
authored
Jan 19, 2020
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1022
parents
0c5ed145
5c6831ab
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
3 deletions
+11
-3
libcaf_core/caf/detail/parser/read_uri.hpp
libcaf_core/caf/detail/parser/read_uri.hpp
+7
-2
libcaf_core/src/detail/append_percent_encoded.cpp
libcaf_core/src/detail/append_percent_encoded.cpp
+1
-1
libcaf_core/test/uri.cpp
libcaf_core/test/uri.cpp
+3
-0
No files found.
libcaf_core/caf/detail/parser/read_uri.hpp
View file @
bf152e63
...
@@ -69,7 +69,8 @@ void read_uri_percent_encoded(State& ps, std::string& str) {
...
@@ -69,7 +69,8 @@ void read_uri_percent_encoded(State& ps, std::string& str) {
}
}
inline
bool
uri_unprotected_char
(
char
c
)
{
inline
bool
uri_unprotected_char
(
char
c
)
{
return
in_whitelist
(
alphanumeric_chars
,
c
)
||
in_whitelist
(
"-._~"
,
c
);
// Consider valid characters not explicitly stated as reserved as unreserved.
return
isprint
(
c
)
&&
!
in_whitelist
(
":/?#[]@!$&'()*+,;=<>"
,
c
);
}
}
// clang-format off
// clang-format off
...
@@ -129,7 +130,9 @@ void read_uri(State& ps, Consumer&& consumer) {
...
@@ -129,7 +130,9 @@ void read_uri(State& ps, Consumer&& consumer) {
return
res
;
return
res
;
};
};
// Allowed character sets.
// Allowed character sets.
auto
path_char
=
[](
char
c
)
{
return
uri_unprotected_char
(
c
)
||
c
==
'/'
;
};
auto
path_char
=
[](
char
c
)
{
return
uri_unprotected_char
(
c
)
||
c
==
'/'
||
c
==
':'
;
};
// Utility setters for avoiding code duplication.
// Utility setters for avoiding code duplication.
auto
set_path
=
[
&
]
{
consumer
.
path
(
take_str
());
};
auto
set_path
=
[
&
]
{
consumer
.
path
(
take_str
());
};
auto
set_host
=
[
&
]
{
consumer
.
host
(
take_str
());
};
auto
set_host
=
[
&
]
{
consumer
.
host
(
take_str
());
};
...
@@ -161,6 +164,8 @@ void read_uri(State& ps, Consumer&& consumer) {
...
@@ -161,6 +164,8 @@ void read_uri(State& ps, Consumer&& consumer) {
epsilon
(
read_path
,
any_char
,
str
+=
'/'
)
epsilon
(
read_path
,
any_char
,
str
+=
'/'
)
}
}
state
(
start_authority
)
{
state
(
start_authority
)
{
// A third '/' skips the authority, e.g., "file:///".
transition
(
read_path
,
'/'
,
str
+=
'/'
)
read_next_char
(
read_authority
,
str
)
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
,
'['
)
}
}
...
...
libcaf_core/src/detail/append_percent_encoded.cpp
View file @
bf152e63
...
@@ -28,6 +28,7 @@ namespace detail {
...
@@ -28,6 +28,7 @@ namespace detail {
void
append_percent_encoded
(
std
::
string
&
str
,
string_view
x
,
bool
is_path
)
{
void
append_percent_encoded
(
std
::
string
&
str
,
string_view
x
,
bool
is_path
)
{
for
(
auto
ch
:
x
)
for
(
auto
ch
:
x
)
switch
(
ch
)
{
switch
(
ch
)
{
case
':'
:
case
'/'
:
case
'/'
:
if
(
is_path
)
{
if
(
is_path
)
{
str
+=
ch
;
str
+=
ch
;
...
@@ -35,7 +36,6 @@ void append_percent_encoded(std::string& str, string_view x, bool is_path) {
...
@@ -35,7 +36,6 @@ void append_percent_encoded(std::string& str, string_view x, bool is_path) {
}
}
CAF_ANNOTATE_FALLTHROUGH
;
CAF_ANNOTATE_FALLTHROUGH
;
case
' '
:
case
' '
:
case
':'
:
case
'?'
:
case
'?'
:
case
'#'
:
case
'#'
:
case
'['
:
case
'['
:
...
...
libcaf_core/test/uri.cpp
View file @
bf152e63
...
@@ -289,6 +289,7 @@ CAF_TEST(from string) {
...
@@ -289,6 +289,7 @@ CAF_TEST(from string) {
// all combinations of components
// all combinations of components
ROUNDTRIP
(
"http:file"
);
ROUNDTRIP
(
"http:file"
);
ROUNDTRIP
(
"http:foo-bar"
);
ROUNDTRIP
(
"http:foo-bar"
);
ROUNDTRIP
(
"http:foo:bar"
);
ROUNDTRIP
(
"http:file?a=1&b=2"
);
ROUNDTRIP
(
"http:file?a=1&b=2"
);
ROUNDTRIP
(
"http:file#42"
);
ROUNDTRIP
(
"http:file#42"
);
ROUNDTRIP
(
"http:file?a=1&b=2#42"
);
ROUNDTRIP
(
"http:file?a=1&b=2#42"
);
...
@@ -359,12 +360,14 @@ CAF_TEST(from string) {
...
@@ -359,12 +360,14 @@ CAF_TEST(from string) {
ROUNDTRIP
(
"http://me@[::1]:80/file?a=1&b=2#42"
);
ROUNDTRIP
(
"http://me@[::1]:80/file?a=1&b=2#42"
);
// percent encoding
// percent encoding
ROUNDTRIP
(
"hi%20there://it%27s@me%21/file%201#%5B42%5D"
);
ROUNDTRIP
(
"hi%20there://it%27s@me%21/file%201#%5B42%5D"
);
ROUNDTRIP
(
"file://localhost/tmp/test/test.{%3A04d}.exr"
);
}
}
#undef ROUNDTRIP
#undef ROUNDTRIP
CAF_TEST
(
empty
components
)
{
CAF_TEST
(
empty
components
)
{
CAF_CHECK_EQUAL
(
"foo:/"
_u
,
"foo:/"
);
CAF_CHECK_EQUAL
(
"foo:/"
_u
,
"foo:/"
);
CAF_CHECK_EQUAL
(
"foo:///"
_u
,
"foo:/"
);
CAF_CHECK_EQUAL
(
"foo:/#"
_u
,
"foo:/"
);
CAF_CHECK_EQUAL
(
"foo:/#"
_u
,
"foo:/"
);
CAF_CHECK_EQUAL
(
"foo:/?"
_u
,
"foo:/"
);
CAF_CHECK_EQUAL
(
"foo:/?"
_u
,
"foo:/"
);
CAF_CHECK_EQUAL
(
"foo:/?#"
_u
,
"foo:/"
);
CAF_CHECK_EQUAL
(
"foo:/?#"
_u
,
"foo:/"
);
...
...
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