-
Notifications
You must be signed in to change notification settings - Fork 50
Escape backslashes properly when converting to the DSL #436
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
Changes from 1 commit
451c907
4c7f595
21b30cb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -114,4 +114,12 @@ extension RenderDSLTests { | |
""") | ||
} | ||
} | ||
|
||
func testQuoting() throws { | ||
try testConversion(#"\\\"a\""#, #""" | ||
Regex { | ||
"\\\"a\"" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this the right conversion? The input is raw, so IIUC it has 3 full backslashes, then a quote then a full backslash and another quote. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll update the test. The |
||
} | ||
"""#) | ||
} | ||
} |
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.
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.
Or we can emit it as a raw string if it has any backslashes or quotes inside it. We could do a quick check to count the number of hashes prior to a backslash and emit a raw string with one additional one.
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 thought about counting hashes, but it seemed like it wasn't worth the effort. But I'm all for using raw strings in your suggested change. I was mostly preserving the way it had been written.