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

Regexp Named groups not working #10395

Open
m0rkeulv opened this issue Mar 26, 2023 · 2 comments
Open

Regexp Named groups not working #10395

m0rkeulv opened this issue Mar 26, 2023 · 2 comments
Labels
avm2 AVM2 (ActionScript 3.0) issues bug Something isn't working

Comments

@m0rkeulv
Copy link

Describe the bug

Flash accepts regexp with named groups and these can be accessed as either indexed elements or properties on the returned object. Flash uses the ?P<name> syntax for defining named groups but this does not work with ruffle and it fails to handle these kind of regular expressions resulting in exec() returning null.

Expected behavior

when named groups are pressent Flash returns result/object while Ruffle returns null.

var namedGroup = /my(?P<groupName>Str)$/m; 
var namedExec = namedGroup.exec("myStr");

trace("index:"+namedExec[1]); //  Flash results in "index:Str" 
// Ruffle : Error #1009: Cannot access a property or method of a null object reference.

trace("named:"+namedExec.groupName); //Flash results in "named:Str"
// Ruffle  Error #1009: Cannot access a property or method of a null object reference.

Affected platform

Desktop app

Operating system

Windows 10

Browser

No response

Additional information

using the named group syntax that the library that ruffle expects (?<name>) do result in named group for the internal structure but it looks like ruffle dont propagate these to the object that is returned so even if the syntax mismatch was to be resolved ruffle still would not allow you to access the named groups by name.

var namedGroup = /my(?<groupName>Str)$/m; 
var namedExec = namedGroup.exec("myStr");
trace("index:"+namedExec[1]); //  the group got a match
trace("named:"+namedExec.groupName); // however the named property does not exists and returns undefined"
@m0rkeulv m0rkeulv added the bug Something isn't working label Mar 26, 2023
@Lord-McSweeney Lord-McSweeney added the avm2 AVM2 (ActionScript 3.0) issues label Mar 26, 2023
@torokati44
Copy link
Member

While we currently rely on regress for this, the possibility of switching to the regex crate instead came up on Discord, so this might be relevant in that case: rust-lang/regex#956

@thaliaarchi
Copy link

@torokati44 Although regex supports this particular syntax for named capture groups, regress supports backreferences, a far more consequential feature, which regex intentionally does not support.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
avm2 AVM2 (ActionScript 3.0) issues bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants