Skip to content

Commit

Permalink
Fix exec escaping for emoji task name (#7813)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
backspace committed Feb 9, 2021
1 parent 7366fa7 commit 24b9a89
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ui/app/utils/escape-task-name.js
Original file line number Diff line number Diff line change
@@ -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, '\\$&');
}
1 change: 1 addition & 0 deletions ui/tests/unit/utils/escape-task-name-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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\\🥳');
});
});

0 comments on commit 24b9a89

Please sign in to comment.