Skip to content
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

Enforce ASCII characters on string and char fields #26

Merged
merged 1 commit into from
Jan 8, 2019

Conversation

hidmic
Copy link
Contributor

@hidmic hidmic commented Jan 4, 2019

This pull request adds ASCII codification and de-codification steps whenever dealing with string and char message fields.

Fixes ros2/ros2cli#176 (which is actually one instance of an issue that is Python support wide).

@tfoote tfoote added the in progress Actively being worked on (Kanban column) label Jan 4, 2019
@hidmic hidmic force-pushed the hidmic/improve-string-handling branch from d58e0a5 to ac4aa82 Compare January 7, 2019 16:49
@hidmic hidmic changed the title [DO NOT MERGE] Handle bad unicode strings. Enforce ASCII characters on string and char fields Jan 7, 2019
@hidmic hidmic requested a review from dirk-thomas January 7, 2019 16:54
@hidmic
Copy link
Contributor Author

hidmic commented Jan 7, 2019

@dirk-thomas I believe you're the best person to review this. Not sure how this plays with (or if it's already fixed in) the refactored IDL code.

@hidmic hidmic added in review Waiting for review (Kanban column) and removed in progress Actively being worked on (Kanban column) labels Jan 7, 2019
@dirk-thomas
Copy link
Member

The patch looks fine to me. Please run CI for the change and maybe add a test to check what happens when passing non-ASCII strings to it.

@hidmic
Copy link
Contributor Author

hidmic commented Jan 7, 2019

Running CI (again, including rclpy test):

  • Linux Build Status
  • Linux-aarch64 Build Status
  • macOS Build Status
  • Windows Build Status

@hidmic
Copy link
Contributor Author

hidmic commented Jan 7, 2019

@dirk-thomas I think that writing a test for this is going to be somewhat involved. The conversions only take place within rclpy C extension code. I'd have to call publish on a message with a non-ascii string field to trigger a check when going from Python to C, and then take a message with a non-ascii string as sent by code that doesn't have such validations (e.g. a C++ node) to trigger a check when going from C to Python. Maybe a candidate for a test_rclpy package in system_tests? An easier alternative might be to write the test in C, using Python's C API.

@dirk-thomas
Copy link
Member

I'd have to call publish on a message with a non-ascii string field to trigger a check when going from Python to C

That part sounds fairly straight forward?

and then take a message with a non-ascii string as sent by code that doesn't have such validations (e.g. a C++ node) to trigger a check when going from C to Python.

If the test only covers the Python-to-C case but not this one that would be sufficient for me.

@hidmic
Copy link
Contributor Author

hidmic commented Jan 7, 2019

That part sounds fairly straight forward?

That's the easy part, yes.

If you're OK with just testing Python-to-C, so am I. But I think we could add the test in rclpy, to avoid adding it as a dependency here.

Copy link
Member

@dirk-thomas dirk-thomas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 with passing CI.

@hidmic
Copy link
Contributor Author

hidmic commented Jan 8, 2019

CI's green now! We're good to go.

@hidmic hidmic merged commit 735bc97 into master Jan 8, 2019
@tfoote tfoote removed the in review Waiting for review (Kanban column) label Jan 8, 2019
@mjcarroll mjcarroll deleted the hidmic/improve-string-handling branch February 28, 2019 17:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants