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

[Issue] Asdoc bug treats "/" within RegExp literals incorrectly as a RegExp delimiter #3246

Open
shaucky opened this issue May 13, 2024 · 3 comments
Labels

Comments

@shaucky
Copy link

shaucky commented May 13, 2024

Problem Description

AIR SDK version: 51.0.1.1

When generating document using asdoc, the forward slash character / within RegExp literals is mistakenly treated as the delimiter for the RegExp, which leads to a compilation failure.

Steps to Reproduce

Code Example:

public static const MAILBOX:RegExp = /^(([\w!#$%&'*+-/=?^_`{|}~]+(\.[\w!#$%&'*+-/=?^_`{|}~]+)*)|("[\x20-\x21\x23-\x5B\x5D-\x7E\x5C\x20-\x7E]*"))@((([A-Za-z0-9][A-Za-z0-9-]*[A-Za-z0-9]?\.)*[A-Za-z0-9][A-Za-z0-9-]*[A-Za-z0-9]?)|\[([0-9]{1,3}\.){3}[0-9]{1,3}\])$/;

(This example is because the bug found when I'm developing a email client library…)

Known Workarounds

Escape the slash / with a backslash \ in RegExp literals, although this should not be necessary according to standards.

@shaucky shaucky added the Bug label May 13, 2024
@ajwfrost
Copy link
Collaborator

I would say this works as expected... the specification here is ECMA-262, 3rd Ed, so if you look at section 7.8.5 you get the grammar for a regular expression literal:

Syntax

RegularExpressionLiteral ::
/ RegularExpressionBody / RegularExpressionFlags

RegularExpressionBody ::
RegularExpressionFirstChar RegularExpressionChars

RegularExpressionChars ::
[empty]
RegularExpressionChars RegularExpressionChar

RegularExpressionFirstChar ::
NonTerminator but not * or \ or /
BackslashSequence

RegularExpressionChar ::
NonTerminator but not \ or /
BackslashSequence

BackslashSequence ::
\ NonTerminator

NonTerminator ::
SourceCharacter but not LineTerminator

So not * or / or \ would imply you can't use a forward-slash, unless it's part of a BackslashSequence...

https://www.ecma-international.org/wp-content/uploads/ECMA-262_3rd_edition_december_1999.pdf

@shaucky
Copy link
Author

shaucky commented May 13, 2024

I see…

But there's a matter that there is a behavioral inconsistency between the ActionScript 3 compiler and asdoc here. Shouldn't asdoc as an annotation tool, prioritize the language itself?

Thanks.

@ajwfrost
Copy link
Collaborator

Ah, I may have misunderstood what you were originally reporting then... I wasn't referring to asdoc, just looking at the regular expression / ActionScript code that you posted.

And oddly, that RegExp compiles fine (well, in terms of the AS3 compiler) when I try that..? Will need to check what should happen here from the compiler perspective as well as from the asdoc side..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants