From: Ingo Schwarze <schwarze@usta.de>
To: Nicolas Joly <njoly@netbsd.org>
Cc: discuss@mdocml.bsd.lv, Thomas Klausner <wiz@netbsd.org>
Subject: Re: Sx quoting and Header
Date: Mon, 27 Dec 2010 22:57:45 +0100 [thread overview]
Message-ID: <20101227215745.GB8732@iris.usta.de> (raw)
In-Reply-To: <20101227132623.GA285025@medusa.sis.pasteur.fr>
Hi Nicolas,
Nicolas Joly wrote on Mon, Dec 27, 2010 at 02:26:23PM +0100:
> This does not work for hrefs ... it does not add the "x" protection
> char because, in that case, *dst = '#' and not '\0'.
Oh indeed. That was sloppy.
Thanks for catching the regression!
> What about letting the caller do the protection instead ?
Hm, your patch is nice too, in particular it's a bit shorter.
On the other hand, doing things required for structural reasons
in one central place is not a bad idea either, it reduces the
risk of forgetting it at one of the several places, in particular
when adding code at a later time.
What finally decided the question is that Kristaps currently
has mdoc_html.c kind of locked, he is working on that very code,
and it will probably change. Interfering with that seemed like
a bad idea, making html_idcat() a bit safer in parallel, on the
other hand, not a problem.
Thanks again,
Ingo
P.S.
Here is what i just committed:
Index: html.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/html.c,v
retrieving revision 1.123
diff -u -p -r1.123 html.c
--- html.c 24 Dec 2010 14:14:00 -0000 1.123
+++ html.c 27 Dec 2010 21:29:35 -0000
@@ -771,20 +771,24 @@ html_idcat(char *dst, const char *src, i
{
int ssz;
- assert(sz);
+ assert(sz > 2);
/* Cf. <http://www.w3.org/TR/html4/types.html#h-6.2>. */
- for ( ; *dst != '\0' && sz; dst++, sz--)
- /* Jump to end. */ ;
-
- assert(sz > 2);
-
/* We can't start with a number (bah). */
- *dst++ = 'x';
- *dst = '\0';
- sz--;
+ if ('#' == *dst) {
+ dst++;
+ sz--;
+ }
+ if ('\0' == *dst) {
+ *dst++ = 'x';
+ *dst = '\0';
+ sz--;
+ }
+
+ for ( ; *dst != '\0' && sz; dst++, sz--)
+ /* Jump to end. */ ;
for ( ; *src != '\0' && sz > 1; src++) {
ssz = snprintf(dst, (size_t)sz, "%.2x", *src);
--
To unsubscribe send an email to discuss+unsubscribe@mdocml.bsd.lv
next prev parent reply other threads:[~2010-12-27 21:57 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-12-25 15:22 Thomas Klausner
2010-12-26 23:30 ` Ingo Schwarze
2010-12-27 0:04 ` Kristaps Dzonsons
2010-12-27 0:36 ` Ingo Schwarze
2010-12-27 8:39 ` Kristaps Dzonsons
[not found] ` <20101227132623.GA285025@medusa.sis.pasteur.fr>
2010-12-27 21:57 ` Ingo Schwarze [this message]
2010-12-27 0:08 ` Ingo Schwarze
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=20101227215745.GB8732@iris.usta.de \
--to=schwarze@usta.de \
--cc=discuss@mdocml.bsd.lv \
--cc=njoly@netbsd.org \
--cc=wiz@netbsd.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.
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).