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

Fix regex encoding: don't assume Windows-31J encoding #35

Merged
merged 1 commit into from
Oct 7, 2019
Merged

Fix regex encoding: don't assume Windows-31J encoding #35

merged 1 commit into from
Oct 7, 2019

Conversation

mttbernardini
Copy link
Contributor

As documented, using the regex flag s implies that the source string encoding is assumed to be Windows-31J. This prevents ronn from compiling valid UTF-8 sources (which actually use Unicode characters and aren't just plain ASCII), reporting the following exception:

/var/lib/gems/2.3.0/gems/ronn-ng-0.8.2/lib/ronn/roff.rb:354:in `gsub': incompatible encoding regexp match (Windows-31J regexp with UTF-8 string) (Encoding::CompatibilityError)

This PR fixes the issue by removing the unneeded flag, which was probably introduced by accident in 3dca20c#diff-8c2a2b56f00218c211ba4fc3ed93077cR358

I hope this helps, let me know.

@apjanke
Copy link
Owner

apjanke commented Oct 7, 2019

Good catch. Yes, the /s flag was introduced by mistake; I thought it had the same effect as in Perl, where it treats a multi-line regexp as a single string.

Merging. Thank you!

@apjanke apjanke merged commit 1e47a67 into apjanke:master Oct 7, 2019
@apjanke apjanke added the bug Something isn't working label Oct 7, 2019
@mttbernardini mttbernardini deleted the regex-encoding-fix branch October 9, 2019 17:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants