Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions extensions/github/scripts/bash/resolve-tasks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,13 @@ json_escape() {
# LC_ALL=C ensures ${#s} counts bytes and ${s:$i:1} yields single bytes,
# so multi-byte UTF-8 sequences (first byte >= 0xC0) pass through intact.
local LC_ALL=C
# Fast path: with no control bytes left there is nothing to escape, so
# skip the byte-by-byte loop, which is slow on large values such as
# template content. [[:cntrl:]] also matches DEL, which takes the loop.
if [[ "$s" != *[[:cntrl:]]* ]]; then
printf '%s' "$s"
return
Comment on lines +76 to +78
fi
local i char code
for (( i=0; i<${#s}; i++ )); do
char="${s:$i:1}"
Expand Down
7 changes: 7 additions & 0 deletions scripts/bash/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,13 @@ json_escape() {
# LC_ALL=C ensures ${#s} counts bytes and ${s:$i:1} yields single bytes,
# so multi-byte UTF-8 sequences (first byte >= 0xC0) pass through intact.
local LC_ALL=C
# Fast path: with no control bytes left there is nothing to escape, so
# skip the byte-by-byte loop, which is slow on large values such as
# template content. [[:cntrl:]] also matches DEL, which takes the loop.
if [[ "$s" != *[[:cntrl:]]* ]]; then
printf '%s' "$s"
return
fi
local i char code
for (( i=0; i<${#s}; i++ )); do
char="${s:$i:1}"
Expand Down
3 changes: 3 additions & 0 deletions tests/extensions/github/test_github_extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -909,6 +909,9 @@ class TestResolveTasksBashJsonEscape:
"tab": "a\tb",
"carriage_return": "a\rb",
"control": "a\x01b",
"escape": "a\x1bb",
"delete": "a\x7fb",
"non_ascii": "aéタ\U0001f4cbb",
}

@staticmethod
Expand Down
Loading