Taitava / obsidian-shellcommands

Execute system commands via hotkeys or command palette in Obsidian (https://obsidian.md). Some automated events are also supported, and execution via URI links.
GNU General Public License v3.0
351 stars 11 forks source link

Fix a latent bug when parsing arguments in variables #152

Closed Taitava closed 2 years ago

Taitava commented 2 years ago

parseShellCommandVariables() uses a poor way to handle argument parsing:

https://github.com/Taitava/obsidian-shellcommands/blob/2b05ffd955ebf57288d9cb03551267c564ff42b5/src/variables/parseShellCommandVariables.ts#L26-L39

When reading arguments from a RegExpExecArray, the function should not rely on removing named properties from the object, and then reading everything that is left in the object. I need to come up with a better solution, but I don't know yet, what it will be.

The problem is that there might be rare cases when the RegExpExecArray object contains more named properties than the three that the function currently removes, in which case the parameter_name variable gets an undefined value.

Caused the following bug reports

When this bug occurs

So far, this bug has been reported to be triggered only when another plugin, Dynamic highlights version 0.1.6 - 0.2.1 is also installed. DH version 0.2.2 does not trigger this bug anymore, but as the bug is still latently present in SC, it needs to be fixed. In theory, it can happen with other plugins too, and also if new regex properties get added to ECMAScript's RegExpExecArray.

Taitava commented 2 years ago

Fixed and will be released in 0.11.0.