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 loading/parsing regular expressions with forward slashes #715

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mamhoff
Copy link

@mamhoff mamhoff commented Feb 4, 2025

This fixes the issue where regular expression would come back slightly different after going through a YAML load/dump cycle. Because we're used to having to escape forward slashes in regular expression literals (because the literal is delimited by slashes), but the deserializer takes the literal output from Regexp#inspect and feeds it as a string into Regexp.new, which expects a string, not a Regexp literal, cycling did not properly work before this commit.

I've also changed the code to be a bit more readable, I hope this doesn't affect performance.

Fixes #523

This fixes the issue where regular expression would come back slightly
different after going through a YAML load/dump cycle. Because we're used
to having to escape forward slashes in regular expression literals
(because the literal is delimited by slashes), but the deserializer
takes the literal output from `Regexp#inspect` and feeds it as a string
into `Regexp.new`, which expects a string, not a Regexp literal, cycling
did not properly work before this commit.

I've also changed the code to be a bit more readable, I hope this
doesn't affect performance.
@mamhoff mamhoff changed the title Fix loading/parsing regular expressions Fix loading/parsing regular expressions with forward slashes Feb 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Dump/Load regexp with escaped slash
1 participant