From: Daniel Shahaf <d.s@daniel.shahaf.name>
To: lolilolicon <lolilolicon@gmail.com>
Cc: zsh-workers@zsh.org
Subject: Re: printf %q segfault
Date: Sun, 16 Oct 2016 16:03:12 +0000 [thread overview]
Message-ID: <20161016160312.GA695@fujitsu.shahaf.local2> (raw)
In-Reply-To: <CAMtVo_N+O_-s-H4-ih=N=oQ5bTRVbgJ9Odk6JCMiv3E-Lzsnmw@mail.gmail.com>
lolilolicon wrote on Sun, Oct 16, 2016 at 22:58:14 +0800:
> The following produces segmentation fault:
>
> printf '%q' 你
>
> produced with zsh 5.2.
>
> Ask if you need any more info.
With latest master it doesn't segfault, but it's not correct, either:
% printf '%q' 你 | xxd
0000000: 2427 5c33 3434 2724 275c 3237 3527 a0 $'\344'$'\275'.
The UTF-8 encoding of your character is E4 BD A0, however, the low byte
(0xA0) is output literally. Since a lone 0xA0 is not a valid UTF-8
sequence, my terminal renders it [if I remove the |xxd pipe] as a U+FFFD
REPLACEMENT CHARACTER instead.
This also reproduces with «printf '%q\n' $'\U00A0'», which should print
either « » (a non-breaking-space) or «$'\302'$'\240'» (the quotestring()
representation of the UTF-8 encoding of U+00A0; that encoding is C2 A0).
Bottom line: the byte 0xA0 should not be printed literally but escaped.
The reason 0xA0 is output literally is that the code takes the "if (itok(*u))"
branch in quotestring(); if it didn't take that branch, it'd behave
correctly.
Cheers,
Daniel
next prev parent reply other threads:[~2016-10-16 16:05 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-16 14:58 lolilolicon
2016-10-16 16:03 ` Daniel Shahaf [this message]
2016-10-18 19:57 ` Peter Stephenson
2016-10-19 8:52 ` Peter Stephenson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20161016160312.GA695@fujitsu.shahaf.local2 \
--to=d.s@daniel.shahaf.name \
--cc=lolilolicon@gmail.com \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).