all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Philipp Stephani <p.stephani2@gmail.com>
Cc: phst@google.com, emacs-devel@gnu.org
Subject: Re: [PATCH] Improve error reporting when serializing non-Unicode strings to JSON
Date: Sat, 23 Dec 2017 18:36:50 +0200	[thread overview]
Message-ID: <83lghtjt99.fsf@gnu.org> (raw)
In-Reply-To: <CAArVCkTHXbMyJPOQqhcAb_QaTnhXO+j=_ViFfekbeTUE2JZ+qA@mail.gmail.com> (message from Philipp Stephani on Sat, 23 Dec 2017 16:20:04 +0000)

> From: Philipp Stephani <p.stephani2@gmail.com>
> Date: Sat, 23 Dec 2017 16:20:04 +0000
> Cc: phst@google.com, emacs-devel@gnu.org
> 
> static void
> json_check_utf8 (Lisp_Object string)
> {
>   eassert (!STRING_MULTIBYTE (string));
>   struct coding_system coding;
>   setup_coding_system (Qutf_8_unix, &coding);
>   /* We initialize only the fields that check_utf_8 accesses.  */
>   coding.src_pos = 0;
>   coding.src_pos_byte = 0;
>   coding.src_chars = SCHARS (string);
>   coding.src_bytes = SBYTES (string);
>   coding.src_object = string;
>   coding.eol_seen = EOL_SEEN_NONE;
>   CHECK_TYPE (check_utf_8 (&coding) >= 0, Qutf_8_string_p, string);
> }
> 
> This apparently fails to detect the unibyte string "u\xFFv" as invalid UTF-8.

How can that be?  0xFF shouldn't pass any of the
UTF_8_n_OCTET_LEADING_P tests, so it should end up in 'else', where
the function returns -1.  Right?

You also need to initialize the head_ascii member, I think.  Maybe its
being uninitialized explains the failure.




  reply	other threads:[~2017-12-23 16:36 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-22 21:00 [PATCH] Improve error reporting when serializing non-Unicode strings to JSON Philipp Stephani
2017-12-23  8:28 ` Eli Zaretskii
2017-12-23 12:33   ` Philipp Stephani
2017-12-23 13:44     ` Eli Zaretskii
2017-12-23 14:29       ` Philipp Stephani
2017-12-23 14:52         ` Eli Zaretskii
2017-12-23 15:00           ` Eli Zaretskii
2017-12-23 15:07             ` Philipp Stephani
2017-12-23 15:19           ` Philipp Stephani
2017-12-23 15:34             ` Eli Zaretskii
2017-12-23 16:20               ` Philipp Stephani
2017-12-23 16:36                 ` Eli Zaretskii [this message]
2017-12-23 16:58                   ` Philipp Stephani
2017-12-23 16:58                     ` Philipp Stephani
2017-12-30 22:20                       ` Philipp Stephani
2017-12-31 15:52                         ` Eli Zaretskii

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=83lghtjt99.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=p.stephani2@gmail.com \
    --cc=phst@google.com \
    /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 external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.