groff-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[groff] 08/10: tmac/an-old.tmac: Drop \*[an-empty] string.


From: G. Branden Robinson
Subject: [groff] 08/10: tmac/an-old.tmac: Drop \*[an-empty] string.
Date: Thu, 17 Sep 2020 05:20:30 -0400 (EDT)

gbranden pushed a commit to branch master
in repository groff.

commit 57f698fe793786df7d2286d79e486d81d7c70898
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Thu Sep 17 00:18:29 2020 +1000

    tmac/an-old.tmac: Drop \*[an-empty] string.
    
    * tmac/an-old.tmac: This string is documented as preventing "looping"
      (presumably infinite) if someone calls a two-font macro with an
      inconvenient parameter; the example shown is ".RB ( \\ )".  This
      string was being interpolated at the end of each argument pair to the
      two-font macros BI, BR, IB, RB, and RI.  This code dates back to groff
      1.10 (dc5351364982f78f8c630f1e856d692d4a82666f, 26 November 1995).
      Did you notice a two-font macro missing?  It was: IR.  Using it fails
      to cause a problem.  So do all of the others when the empty string
      interpolation is removed.  Presumably at some point in the past 25
      years, this workaround became unnecessary.
    
      (BI, BR, IB, RB, RI): Remove interpolations of string.
    
    * tmac/tests/an-old_avoid_two-font_denial_of_service.sh: Add regression
      test.
    
    * tmac/tmac.am: Run the test.
---
 ChangeLog                                          | 20 ++++++++++++
 tmac/an-old.tmac                                   | 12 +++-----
 .../an-old_avoid_two-font_denial_of_service.sh     | 36 ++++++++++++++++++++++
 tmac/tmac.am                                       |  1 +
 4 files changed, 62 insertions(+), 7 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index d64699c..5bc1181 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,23 @@
+2020-09-17  G. Branden Robinson <g.branden.robinson@gmail.com>
+
+       tmac/an-old.tmac: Drop \*[an-empty] string.  This string is
+       documented as preventing "looping" (presumably infinite) if
+       someone calls a two-font macro with an inconvenient parameter;
+       the example shown is ".RB ( \\ )".  This string was being
+       interpolated at the end of each argument pair to the two-font
+       macros BI, BR, IB, RB, and RI.  This code dates back to groff
+       1.10 (dc5351364982f78f8c630f1e856d692d4a82666f, 26 November
+       1995).  Did you notice a two-font macro missing?  It was: IR.
+       Using it fails to cause a problem.  So do all of the others when
+       the empty string interpolation is removed.  Presumably at some
+       point in the past 25 years, this workaround became unnecessary.
+       (BI, BR, IB, RB, RI): Remove interpolations of string.
+
+       * tmac/tests/an-old_avoid_two-font_denial_of_service.sh: Add
+       regression test.
+
+       * tmac/tmac.am: Run the test.
+
 2020-09-16  G. Branden Robinson <g.branden.robinson@gmail.com>
 
        tmac/an-old.tmac: Refactor continuous rendering handling.
diff --git a/tmac/an-old.tmac b/tmac/an-old.tmac
index 9d2a489..e4e6c35 100644
--- a/tmac/an-old.tmac
+++ b/tmac/an-old.tmac
@@ -480,14 +480,12 @@
 .  ns
 ..
 .
-.ds an-empty \" this is referenced to avoid looping on, e.g., .RB ( \\ )
-.
 .de1 RI
 .  if \\n[.$] \{\
 .    ds an-result \&\f[R]\\$1\"
 .    shift
 .    while (\\n[.$] >= 2) \{\
-.      as an-result \,\f[I]\\$1\f[R]\/\\$2\\*[an-empty]\"
+.      as an-result \,\f[I]\\$1\f[R]\/\\$2\"
 .      shift 2
 .    \}
 .    if \\n[.$] .as an-result \,\f[I]\\$1\"
@@ -515,7 +513,7 @@
 .    ds an-result \&\f[I]\,\\$1\"
 .    shift
 .    while (\\n[.$] >= 2) \{\
-.      as an-result \/\f[B]\\$1\f[I]\,\\$2\\*[an-empty]\"
+.      as an-result \/\f[B]\\$1\f[I]\,\\$2\"
 .      shift 2
 .    \}
 .    if \\n[.$] .as an-result \/\f[B]\\$1\"
@@ -529,7 +527,7 @@
 .    ds an-result \&\f[B]\\$1\"
 .    shift
 .    while (\\n[.$] >= 2) \{\
-.      as an-result \,\f[I]\\$1\f[B]\/\\$2\\*[an-empty]\"
+.      as an-result \,\f[I]\\$1\f[B]\/\\$2\"
 .      shift 2
 .    \}
 .    if \\n[.$] .as an-result \,\f[I]\\$1\"
@@ -541,7 +539,7 @@
 .de1 RB
 .  ds an-result \&\"
 .  while (\\n[.$] >= 2) \{\
-.    as an-result \f[R]\\$1\f[B]\\$2\\*[an-empty]\"
+.    as an-result \f[R]\\$1\f[B]\\$2\"
 .    shift 2
 .  \}
 .  if \\n[.$] .as an-result \f[R]\\$1\"
@@ -552,7 +550,7 @@
 .de1 BR
 .  ds an-result \&\"
 .  while (\\n[.$] >= 2) \{\
-.    as an-result \f[B]\\$1\f[R]\\$2\\*[an-empty]\"
+.    as an-result \f[B]\\$1\f[R]\\$2\"
 .    shift 2
 .  \}
 .  if \\n[.$] .as an-result \f[B]\\$1\"
diff --git a/tmac/tests/an-old_avoid_two-font_denial_of_service.sh 
b/tmac/tests/an-old_avoid_two-font_denial_of_service.sh
new file mode 100755
index 0000000..2ba1822
--- /dev/null
+++ b/tmac/tests/an-old_avoid_two-font_denial_of_service.sh
@@ -0,0 +1,36 @@
+#!/bin/sh
+#
+# Copyright (C) 2020 Free Software Foundation, Inc.
+#
+# This file is part of groff.
+#
+# groff is free software; you can redistribute it and/or modify it under
+# the terms of the GNU General Public License as published by the Free
+# Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# groff is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+
+groff="${abs_top_builddir:-.}/test-groff"
+
+# That's six pairs of parentheses below.
+"$groff" -Tascii -P-cbou -man <<EOF | grep -q '( ) ( ) ( ) ( ) ( ) ( )'
+.TH sample 1 2020-09-16 "groff test suite"
+.SH Name
+sample \- test subject for groff
+.PP
+Don't DoS me, bro!
+.BI ( \\ )
+.BR ( \\ )
+.IB ( \\ )
+.IR ( \\ )
+.RB ( \\ )
+.RI ( \\ )
+EOF
diff --git a/tmac/tmac.am b/tmac/tmac.am
index 8119ed8..03425d5 100644
--- a/tmac/tmac.am
+++ b/tmac/tmac.am
@@ -153,6 +153,7 @@ tmac_TESTS = \
   tmac/tests/an-old_LL_init_sanely.sh \
   tmac/tests/an-old_TH_repairs_ad_damage.sh \
   tmac/tests/an-old_TH_repairs_hy_damage.sh \
+  tmac/tests/an-old_avoid_two-font_denial_of_service.sh \
   tmac/tests/doc-accept-mixed-case-section-headings.sh \
   tmac/tests/doc-smoke-test.sh
 TESTS += $(tmac_TESTS)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]