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

Unescaped literal commas are not identified correctly #11

Open
Lexikos opened this issue Jun 21, 2021 · 0 comments
Open

Unescaped literal commas are not identified correctly #11

Lexikos opened this issue Jun 21, 2021 · 0 comments

Comments

@Lexikos
Copy link

Lexikos commented Jun 21, 2021

MsgBox, Hello, world!  ; old
MsgBox "Hello", "world!"  ; new (incorrect)
MsgBox "Hello, world!"  ; correct

For most commands, commas in the last parameter do not need to be escaped; i.e. they are automatically literal. The second number in each g_act entry indicates the maximum number of parameters.

However, MsgBox has special handling for comma, so:

  • If the first apparent parameter (Options) does not have the % force-expression prefix and is not a positive integer such as 48 or empty, the command is treated as having maximum 1 parameter (all commas are literal).
  • If the third apparent parameter (Text) has the % force-expression prefix, the command is treated as normal (maximum 4 parameters).
  • If the fourth apparent parameter (Timeout) does not have the % force-expression prefix and is not a positive number such as 1.0 or empty, the command is treated as having maximum 3 parameters (so all commas in the third parameter are literal).

When there is an expression parameter, splitting the parameters correctly requires matching up (), [] and {} (i.e. any comma enclosed within them does not delimit command parameters).

MsgBox 48, Title, Text, 1.0  ; all commas are delimiters
MsgBox, , Title, Text,  ; as above
MsgBox % Options, Title, Text, % Timeout  ; as above
MsgBox 16,, Hello, world!  ; only the first two commas delimit parameters
MsgBox % Options,, Hello, world!  ; as above
MsgBox Options, Title, Text, Timeout  ; ignore the words, this is all just one Text parameter
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

1 participant