Fix exec escaping for emoji task name (#7813)

This closes #7459.

While emoji don’t actually need escaping, expanding the
expression that enumerates all task name characters that
don’t need escaping to include emoji is prohibitive, since
it’s a discontinuous range. The emoji-regex project has
such an expression and it’s 12kB.

This fixes the regular expression to property escape emoji
as a single character instead of as its component bytes.
Thanks to @DingoEatingFuzz for the suggestion.
This commit is contained in:
Buck Doyle 2021-02-09 09:33:48 -06:00 committed by GitHub
parent a412513c65
commit e3392b7da8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 1 deletions

View File

@ -1,4 +1,4 @@
export default function escapeTaskName(taskName) {
// Regular expression is taken from here: https://stackoverflow.com/a/20053121
return taskName.replace(/[^a-zA-Z0-9,._+@%/-]/g, '\\$&');
return taskName.replace(/[^a-zA-Z0-9,._+@%/-]/gu, '\\$&');
}

View File

@ -6,5 +6,6 @@ module('Unit | Utility | escape-task-name', function() {
assert.equal(escapeTaskName('plain'), 'plain');
assert.equal(escapeTaskName('a space'), 'a\\ space');
assert.equal(escapeTaskName('dollar $ign'), 'dollar\\ \\$ign');
assert.equal(escapeTaskName('emoji🥳'), 'emoji\\🥳');
});
});