mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-03-27 14:45:13 +08:00
Encode all ENCODE_DIRECT codepoints with encode_direct
forward-port of 09986f5563e31e2c900a606438f1d60d008f3a14
This commit is contained in:
parent
e380654fff
commit
eb196c8330
@ -979,6 +979,9 @@ pub fn read_unquoted_escape(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if let Some(c) = result_char_or_none {
|
if let Some(c) = result_char_or_none {
|
||||||
|
if fish_reserved_codepoint(c) {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
result.push(c);
|
result.push(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1134,9 +1137,7 @@ pub fn str2wcstring(inp: &[u8]) -> WString {
|
|||||||
Some(codepoint) => {
|
Some(codepoint) => {
|
||||||
c = codepoint;
|
c = codepoint;
|
||||||
// Determine whether to encode this character with our crazy scheme.
|
// Determine whether to encode this character with our crazy scheme.
|
||||||
(c >= ENCODE_DIRECT_BASE && c < ENCODE_DIRECT_END)
|
fish_reserved_codepoint(c)
|
||||||
||
|
|
||||||
c == INTERNAL_SEPARATOR
|
|
||||||
||
|
||
|
||||||
// Incomplete sequence.
|
// Incomplete sequence.
|
||||||
ret == 0_usize.wrapping_sub(2)
|
ret == 0_usize.wrapping_sub(2)
|
||||||
|
@ -328,12 +328,10 @@ static wcstring str2wcs_internal(const char *in, const size_t in_len) {
|
|||||||
} else {
|
} else {
|
||||||
ret = std::mbrtowc(&wc, &in[in_pos], in_len - in_pos, &state);
|
ret = std::mbrtowc(&wc, &in[in_pos], in_len - in_pos, &state);
|
||||||
// Determine whether to encode this character with our crazy scheme.
|
// Determine whether to encode this character with our crazy scheme.
|
||||||
if (wc >= ENCODE_DIRECT_BASE && wc < ENCODE_DIRECT_BASE + 256) {
|
if (fish_reserved_codepoint(wc)) {
|
||||||
use_encode_direct = true;
|
use_encode_direct = true;
|
||||||
} else if ((wc >= 0xD800 && wc <= 0xDFFF) || static_cast<uint32_t>(wc) >= 0x110000) {
|
} else if ((wc >= 0xD800 && wc <= 0xDFFF) || static_cast<uint32_t>(wc) >= 0x110000) {
|
||||||
use_encode_direct = true;
|
use_encode_direct = true;
|
||||||
} else if (wc == INTERNAL_SEPARATOR) {
|
|
||||||
use_encode_direct = true;
|
|
||||||
} else if (ret == static_cast<size_t>(-2)) {
|
} else if (ret == static_cast<size_t>(-2)) {
|
||||||
// Incomplete sequence.
|
// Incomplete sequence.
|
||||||
use_encode_direct = true;
|
use_encode_direct = true;
|
||||||
|
@ -612,6 +612,14 @@ $fish -c begin
|
|||||||
echo $status
|
echo $status
|
||||||
# CHECK: 127
|
# CHECK: 127
|
||||||
|
|
||||||
|
$fish -c 'echo \ufdd2"fart"'
|
||||||
|
# CHECKERR: fish: Invalid token '\ufdd2"fart"'
|
||||||
|
# CHECKERR: echo \ufdd2"fart"
|
||||||
|
# CHECKERR: ^~~~~~~~~~~^
|
||||||
|
|
||||||
|
echo (printf '\ufdd2foo') | string escape
|
||||||
|
# CHECK: \Xef\Xb7\X92foo
|
||||||
|
|
||||||
printf '%s\n' "#!/bin/sh" 'echo $0' > $tmpdir/argv0.sh
|
printf '%s\n' "#!/bin/sh" 'echo $0' > $tmpdir/argv0.sh
|
||||||
chmod +x $tmpdir/argv0.sh
|
chmod +x $tmpdir/argv0.sh
|
||||||
cd $tmpdir
|
cd $tmpdir
|
||||||
|
Loading…
x
Reference in New Issue
Block a user