Skip to content

Unescaped literal commas are not identified correctly #11

@Lexikos

Description

@Lexikos
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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions