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

Invalid flags supplied to RegExp constructor 'n #1508

Closed
h4ck3rm1k3 opened this issue Jul 5, 2016 · 6 comments
Closed

Invalid flags supplied to RegExp constructor 'n #1508

h4ck3rm1k3 opened this issue Jul 5, 2016 · 6 comments

Comments

@h4ck3rm1k3
Copy link
Contributor

SyntaxError: Invalid flags supplied to RegExp constructor 'n'

error

Invalid flags supplied to RegExp constructor 'n

input

UTF8_RE = /\A(?:
        [\x00-\x7f]
       |[\xc0-\xdf][\x80-\xbf]
       |[\xe0-\xef][\x80-\xbf][\x80-\xbf]
       |[\xf0-\xf7][\x80-\xbf][\x80-\xbf][\x80-\xbf]
       |[\xf8-\xfb][\x80-\xbf][\x80-\xbf][\x80-\xbf][\x80-\xbf]
       |[\xfc-\xfd][\x80-\xbf][\x80-\xbf][\x80-\xbf][\x80-\xbf][\x80-\xbf])\Z/nx;

source

https://github.com/boukeversteegh/chise/blob/342df4be600e2e9790cba880dd9b3cf54c436831/ruby/chise/string.rb

@iliabylich
Copy link
Contributor

This flag is not supported by native javascript regexps and it can't be fixed without using shims like XRegExp. See #591 for more information

@h4ck3rm1k3
Copy link
Contributor Author

This is still a bug, it is unsupported code that is valid ruby. If we are going to claim it is a ruby compiler, we need to keep this open.

@elia
Copy link
Member

elia commented Jul 5, 2016

If we are going to claim it is a ruby compiler, we need to keep this open.

Yes, but it's enough to keep track of this under the umbrella issue that is #591. The deal for now is that native JS regexps are used (as we do with numbers, arrays, and procs).

@h4ck3rm1k3
Copy link
Contributor Author

xarasho

@h4ck3rm1k3
Copy link
Contributor Author

the flag \n means ascii encoding.
http://ruby-doc.org/core-2.1.1/Regexp.html

Regular expressions are assumed to use the source encoding. This can be overridden with one of the following modifiers.
/pat/u - UTF-8
/pat/e - EUC-JP
/pat/s - Windows-31J
/pat/n - ASCII-8BIT

So I was able to transform them into unicode constants

  |[\xc0-\xdf][\x80-\xbf]

becomes

 |[\u00c0-\u00df][\u0080-\u00bf]

So I think the compiler could support that easily.

@h4ck3rm1k3
Copy link
Contributor Author

I would like to treat this a separate issue, because I don't see the encoding types being handled in the other issue. If unsupported please mark as such.

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

No branches or pull requests

3 participants