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 line breaks ruining call tag regexp #109

Merged
merged 1 commit into from
May 5, 2016
Merged

Conversation

kirsle
Copy link
Member

@kirsle kirsle commented May 5, 2016

Per issue #108, if you used a line break sequence "\n" inside a <call> tag, it would break the regular expression trying to match the <call>...</call> sequence because this regexp couldn't handle line breaks.

JavaScript regexp doesn't support the /.../s flag which would make the . metacharacter match line break characters. The workaround is to replace the . metacharacter with the sequence [\s\S] to match spaces and non-space characters (essentially forcing it to match everything, including line breaks).

- callRe = /<call>(.+?)<\/call>/ig
+ callRe = /<call>([\s\S]+?)<\/call>/ig

Additionally, I changed the code to call the new utils.trim() function (which is a more compatible version of String.prototype.trim() to support Internet Explorer < 9) instead of the utils.strip() function -- because that function would remove line breaks anywhere in a string, negating the whole point of allowing "\n" to appear inside a <call> tag.

This code fixes #108.

@kirsle kirsle merged commit 1e46bee into master May 5, 2016
@kirsle kirsle deleted the bug/108-call-arg-newline branch May 5, 2016 22:26
@davidchriqui
Copy link

Thanks for the reactivity.

However, your fix causes "string1\nstring1" to be troncated to "string1"

@kirsle
Copy link
Member Author

kirsle commented May 6, 2016

Can you give me an example? When I tested it with your example from #108 it worked for me.

@davidchriqui
Copy link

My bad. It does work. Thank you ;)

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.

calling an object macro with "\n" in an argument string => not working
2 participants