mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-25 08:56:43 +08:00
Encode all ENCODE_DIRECT codepoints with encode_direct
This commit is contained in:
parent
c0de5dd804
commit
09986f5563
|
@ -335,9 +335,7 @@ static wcstring str2wcs_internal(const char *in, const size_t in_len) {
|
|||
} else {
|
||||
ret = std::mbrtowc(&wc, &in[in_pos], in_len - in_pos, &state);
|
||||
// Determine whether to encode this character with our crazy scheme.
|
||||
if (wc >= ENCODE_DIRECT_BASE && wc < ENCODE_DIRECT_BASE + 256) {
|
||||
use_encode_direct = true;
|
||||
} else if (wc == INTERNAL_SEPARATOR) {
|
||||
if (fish_reserved_codepoint(wc)) {
|
||||
use_encode_direct = true;
|
||||
} else if (ret == static_cast<size_t>(-2)) {
|
||||
// Incomplete sequence.
|
||||
|
@ -1313,6 +1311,9 @@ maybe_t<size_t> read_unquoted_escape(const wchar_t *input, wcstring *result, boo
|
|||
}
|
||||
|
||||
if (result_char_or_none.has_value()) {
|
||||
if (fish_reserved_codepoint(*result_char_or_none)) {
|
||||
return none();
|
||||
}
|
||||
result->push_back(*result_char_or_none);
|
||||
}
|
||||
|
||||
|
|
|
@ -587,6 +587,14 @@ $fish -c 'echo \x'
|
|||
# CHECKERR: echo \x
|
||||
# CHECKERR: ^^
|
||||
|
||||
$fish -c 'echo \ufdd2"fart"'
|
||||
# CHECKERR: fish: Invalid token '\ufdd2"fart"'
|
||||
# CHECKERR: echo \ufdd2"fart"
|
||||
# CHECKERR: ^~~~~~~~~~~^
|
||||
|
||||
echo (sh -c 'printf $\'\ufdd2foo\'') | string escape
|
||||
# CHECK: \Xef\Xb7\X92foo
|
||||
|
||||
printf '%s\n' "#!/bin/sh" 'echo $0' > $tmpdir/argv0.sh
|
||||
chmod +x $tmpdir/argv0.sh
|
||||
cd $tmpdir
|
||||
|
|
Loading…
Reference in New Issue
Block a user