From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: from mandoc.bsd.lv (bsd.lv [66.111.2.12]) by inbox.vuxu.org (Postfix) with ESMTP id 9BC7C28BC6 for ; Tue, 13 Aug 2024 14:44:32 +0200 (CEST) Received: from fantadrom.bsd.lv (localhost [127.0.0.1]) by mandoc.bsd.lv (OpenSMTPD) with ESMTP id 29c7a3c9 for ; Tue, 13 Aug 2024 12:44:30 +0000 (UTC) Received: from localhost (mandoc.bsd.lv [local]) by mandoc.bsd.lv (OpenSMTPD) with ESMTPA id af94e783 for ; Tue, 13 Aug 2024 12:44:30 +0000 (UTC) Date: Tue, 13 Aug 2024 12:44:30 +0000 (UTC) X-Mailinglist: mandoc-source Reply-To: source@mandoc.bsd.lv MIME-Version: 1.0 From: schwarze@mandoc.bsd.lv To: source@mandoc.bsd.lv Subject: mandoc: Fix a bug in .Ql handling that has been present since the X-Mailer: activitymail 1.26, http://search.cpan.org/dist/activitymail/ Content-Type: text/plain; charset=utf-8 Message-ID: <6b9c6c64bd070c61@mandoc.bsd.lv> Log Message: ----------- Fix a bug in .Ql handling that has been present since the beginning (2017). Since the .Ql macro action uses an output prefix of "'`" and an output suffix of "`'", md_post_raw() would decrement the code_blocks state variable even though md_pre_raw() had earlier neglected to increment it, hence leaving the variable in an invalid negative state. That in turn could result in corrupt output in a variety of ways. Fix this by checking in md_pre_raw() whether the prefix *contains* a backtick rather than only checking whether it *starts* with a backtick. For consistency, apply the same change to md_post_raw() even though there was no bug in that function: all *suffixes* containing a backtick actually contain it in the leading position. Thanks to job@ for reporting this bug. He noticed a particularly nasty kind of output corruption: having .Ql in an input file would result in ASCII_NBRSP (0x31) sneaking through into the output stream if later, unrelated parts of the same input file directly or indirectly used the \~ escape sequence, for example by using the .Ex macro. Modified Files: -------------- mandoc: mdoc_markdown.c Revision Data ------------- Index: mdoc_markdown.c =================================================================== RCS file: /home/cvs/mandoc/mandoc/mdoc_markdown.c,v diff -Lmdoc_markdown.c -Lmdoc_markdown.c -u -p -r1.37 -r1.38 --- mdoc_markdown.c +++ mdoc_markdown.c @@ -750,7 +750,7 @@ md_pre_raw(struct roff_node *n) if ((prefix = md_act(n->tok)->prefix) != NULL) { md_rawword(prefix); outflags &= ~MD_spc; - if (*prefix == '`') + if (strchr(prefix, '`') != NULL) code_blocks++; } return 1; @@ -764,7 +764,7 @@ md_post_raw(struct roff_node *n) if ((suffix = md_act(n->tok)->suffix) != NULL) { outflags &= ~(MD_spc | MD_nl); md_rawword(suffix); - if (*suffix == '`') + if (strchr(suffix, '`') != NULL) code_blocks--; } } -- To unsubscribe send an email to source+unsubscribe@mandoc.bsd.lv