Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
44581dbe
Commit
44581dbe
authored
Oct 29, 2013
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
util/UriUtil: add uri_is_child_or_same()
parent
205448c1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
0 deletions
+31
-0
UriUtil.cxx
src/util/UriUtil.cxx
+18
-0
UriUtil.hxx
src/util/UriUtil.hxx
+13
-0
No files found.
src/util/UriUtil.cxx
View file @
44581dbe
...
...
@@ -106,3 +106,21 @@ uri_remove_auth(const char *uri)
result
.
erase
(
auth
-
uri
,
at
+
1
-
auth
);
return
result
;
}
bool
uri_is_child
(
const
char
*
parent
,
const
char
*
child
)
{
assert
(
parent
!=
nullptr
);
assert
(
child
!=
nullptr
);
const
size_t
parent_length
=
strlen
(
parent
);
return
memcmp
(
parent
,
child
,
parent_length
)
==
0
&&
child
[
parent_length
]
==
'/'
;
}
bool
uri_is_child_or_same
(
const
char
*
parent
,
const
char
*
child
)
{
return
strcmp
(
parent
,
child
)
==
0
||
uri_is_child
(
parent
,
child
);
}
src/util/UriUtil.hxx
View file @
44581dbe
...
...
@@ -57,4 +57,17 @@ gcc_pure
std
::
string
uri_remove_auth
(
const
char
*
uri
);
/**
* Check whether #child specifies a resource "inside" the directory
* specified by #parent. If the strings are equal, the function
* returns false.
*/
gcc_pure
gcc_nonnull_all
bool
uri_is_child
(
const
char
*
parent
,
const
char
*
child
);
gcc_pure
gcc_nonnull_all
bool
uri_is_child_or_same
(
const
char
*
parent
,
const
char
*
child
);
#endif
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