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

Projects
None yet
3 participants
@hidmic
Copy link
Contributor

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 label Jan 4, 2019

@hidmic hidmic force-pushed the hidmic/improve-string-handling branch from d58e0a5 to ac4aa82 Jan 7, 2019

@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 Jan 7, 2019

@hidmic

This comment has been minimized.

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 and removed in progress labels Jan 7, 2019

@dirk-thomas

This comment has been minimized.

Copy link
Member

dirk-thomas commented Jan 7, 2019

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

This comment has been minimized.

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

This comment has been minimized.

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

This comment has been minimized.

Copy link
Member

dirk-thomas commented Jan 7, 2019

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

This comment has been minimized.

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.

@dirk-thomas
Copy link
Member

dirk-thomas left a comment

👍 with passing CI.

@hidmic

This comment has been minimized.

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

1 check failed

Cpr__rosidl_python__ubuntu_bionic_amd64 Build finished.
Details

@tfoote tfoote removed the in review label Jan 8, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment