* [BUG] Issue with pattern meta characters passed to :A
@ 2018-01-12 21:56 dana
0 siblings, 0 replies; only message in thread
From: dana @ 2018-01-12 21:56 UTC (permalink / raw)
To: zsh-workers
Hey there. I ran into the following problem today:
% print -r ${${:-a-b}:a}
/Users/dana/a-b
% print -r ${${:-a-b}:A}
/Users/dana/a?b
The ? in the second one is 0x9b (Dash).
Both chabspath() (:a) and chrealpath() (:A) receive the input as $'a\x9bb'. :a
doesn't care, because all it's doing is manipulating '.' and '/' in the string.
It is a concern for :A, though, because it has to pass the string to realpath(),
and then it has to metafy() the result. There are two related issues, then:
1. chrealpath() can't resolve paths passed into it this way if they contain
pattern meta characters (any of them, not just '-'). It calls unmetafy(), but
that doesn't help here.
2. chrealpath() metafies the result at the end, converting (e.g.) $'.../a\x9bb'
into $'.../a\x83\xbbb', which breaks the expansion even in cases where it'd
be *accidentally* correct (like the one above).
(Quoting/escaping the expansion works around these. So does assigning 'a-b' to a
variable first, as long as you don't do something like ${${~str}:A}.)
Simply having chrealpath() call untokenize() after unmetafy() fixes the above
test case, but then there's a new problem: ${:-a-b} and ${:-$'a\x9bb'} are
indistinguishable to the function and thus give the same result. This would
break resolution of multi-byte file names, as in ${${:-ツ}:A} (ツ = $'\u30c4' =
$'\xe3\x83\x84').
Not sure how to fix properly. Metafication/tokenisation stuff is still pretty
confusing to me.
dana
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2018-01-12 21:56 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-12 21:56 [BUG] Issue with pattern meta characters passed to :A dana
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).