-
Notifications
You must be signed in to change notification settings - Fork 167
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add general check for yaml on rcl_yaml_param_parser #809
add general check for yaml on rcl_yaml_param_parser #809
Conversation
/// Validate a name whether it is a valid namespace | ||
/// | ||
static rcutils_ret_t | ||
__validate_namespace(const char * name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why it should not be dependent on rmw
? could you elaborate a little bit? I think it would be better to use rmw
to validate the namespace instead of having redundant code else where.
I found that using rmw_validate_namespace has some limitations because there are some extra rules, such as "/**" (maybe more in the future), need to be parsed.
you mean ros2/rclcpp#1265?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your questions, @fujitatomoya
why it should not be dependent on rmw?
"/**" is a special rule at rclcpp
, it is invalid checked by rmw_validate_namespace
.
If using rmw_validate_namespace
, we need to add more extra checking for these special rules inside __validate_namespace
, which seems not a requirement of this issue.
maybe more in the future
you mean ros2/rclcpp#1265?
Yes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Though this solves the reported issue, I think we should do a more general check if the node namespace (and node name) are valid. I would do this using rmw_validate_namespace
and rmw_validate_node_name
, and handle the special cases for wildcards *
and **
.
I suggest implementing this function as follows:
- Make a copy of the name to validate
- Substitute substrings
*
and**
with arbitrary valid strings (e.g.WILDCARD
) - Pass the modified name to
rmw_validate_namespace
By using the rmw functions we are consistent with what it means to be a valid name.
What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest implementing this function as follows
Thanks for your suggestion. I'll update it later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should also validate the node name. If you don't want to add it to this PR, we do it in a follow-up.
/// Validate a name whether it is a valid namespace | ||
/// | ||
static rcutils_ret_t | ||
__validate_namespace(const char * name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Though this solves the reported issue, I think we should do a more general check if the node namespace (and node name) are valid. I would do this using rmw_validate_namespace
and rmw_validate_node_name
, and handle the special cases for wildcards *
and **
.
I suggest implementing this function as follows:
- Make a copy of the name to validate
- Substitute substrings
*
and**
with arbitrary valid strings (e.g.WILDCARD
) - Pass the modified name to
rmw_validate_namespace
By using the rmw functions we are consistent with what it means to be a valid name.
What do you think?
Signed-off-by: Chen Lihui <[email protected]>
Signed-off-by: Chen Lihui <[email protected]>
Signed-off-by: Chen Lihui <[email protected]>
This reverts commit b847544. Signed-off-by: Chen Lihui <[email protected]>
This reverts commit 52bb028. Signed-off-by: Chen Lihui <[email protected]>
Signed-off-by: Chen Lihui <[email protected]>
1c5ac73
to
682d4db
Compare
After rebasing from BTW: I didn't add some extra rules which are not merged (such as ros2/rclcpp#1265) in this PR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
Could you also add a test for the /**
case? Thanks!
Signed-off-by: Chen Lihui <[email protected]>
Signed-off-by: Chen Lihui <[email protected]>
Signed-off-by: Chen Lihui <[email protected]>
I have added the test and added additional rules for wildcards based on ros2/design#303. |
Signed-off-by: Chen Lihui <[email protected]>
Signed-off-by: Chen Lihui <[email protected]>
…partial matches Signed-off-by: Chen Lihui <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Signed-off-by: Chen Lihui <[email protected]>
The |
@ros-pull-request-builder retest this please |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure about the cppcheck failure on macOS or the Windows build failure 🤔
rcl_yaml_param_parser/src/parse.c
Outdated
/// \return RCUTILS_RET_ERROR if an unspecified error occurred. | ||
RCL_YAML_PARAM_PARSER_LOCAL | ||
rcutils_ret_t | ||
__validate_namespace(const char * namespace); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should use a single underscore. Double underscores are reserved identifiers.
__validate_namespace(const char * namespace); | |
_validate_namespace(const char * namespace); |
Same for other functions names below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's good to know.
the version of |
Co-authored-by: Jacob Perron <[email protected]> Signed-off-by: Chen Lihui <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks for iterating!
Fixes #301
Signed-off-by: Chen Lihui [email protected]
Updated: Besides fixing to not allow '//' in node name, adding the general check and some special rules about wildcards(including some new rules on ros2/design#303)