texinfo-commits
[Top][All Lists]
Advanced

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

[7636] xrefs_of_manpage


From: gavinsmith0123
Subject: [7636] xrefs_of_manpage
Date: Thu, 19 Jan 2017 15:55:22 -0500 (EST)

Revision: 7636
          http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=7636
Author:   gavin
Date:     2017-01-19 15:55:22 -0500 (Thu, 19 Jan 2017)
Log Message:
-----------
xrefs_of_manpage

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/info/man.c

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog     2017-01-17 21:02:32 UTC (rev 7635)
+++ trunk/ChangeLog     2017-01-19 20:55:22 UTC (rev 7636)
@@ -1,3 +1,10 @@
+2017-01-19  Gavin Smith  <address@hidden>
+
+       * info/man.c (xrefs_of_manpage): Check that names of man pages
+       only contain certain characters, and don't allow "0" as the 
+       section number.  This reduces the chance of incorrectly
+       identifying text in a man page as a cross-reference.
+
 2017-01-18  Gavin Smith  <address@hidden>
 
        * info/man.c (xrefs_of_manpage): Fix code finding end of the

Modified: trunk/info/man.c
===================================================================
--- trunk/info/man.c    2017-01-17 21:02:32 UTC (rev 7635)
+++ trunk/info/man.c    2017-01-19 20:55:22 UTC (rev 7636)
@@ -503,18 +503,41 @@
       register int name, name_end;
       int section, section_end;
 
-      for (name = position; name > 0; name--)
-        if (whitespace_or_newline (s.buffer[name]))
+      name = position;
+      if (name == 0)
+        goto skip;
+      else
+        name--;
+
+      /* Go to the start of a sequence of non-whitespace characters,
+         checking the characters are those that should appear in a man
+         page name. */
+      for (; name > 0; name--)
+        if (whitespace_or_newline (s.buffer[name])
+            || (!isalnum (s.buffer[name])
+                && s.buffer[name] != '_'
+                && s.buffer[name] != '.'
+                && s.buffer[name] != '-'
+                && s.buffer[name] != '\033'
+                && s.buffer[name] != '['))
           break;
 
+      /* Check if reached start of buffer. */
       if (name == 0)
         goto skip;
+
+      /* Check for invalid sequence in name. */
+      if (!whitespace_or_newline (s.buffer[name]))
+        goto skip;
+
       name++;
 
       if (name == position)
         goto skip; /* Whitespace immediately before '('. */
 
-      /* If we are on an ECMA-48 SGR escape sequence, skip past it. */
+      /* 'name' is now at the start of a sequence of non-whitespace
+         characters.  If we are on an ECMA-48 SGR escape sequence, skip
+         past it. */
       if (s.buffer[name] == '\033' && s.buffer[name + 1] == '[')
         {
           name += 2;
@@ -525,6 +548,7 @@
             goto skip;
         }
 
+      /* Set name_end to the end of the name, but before any SGR sequence. */
       for (name_end = name; name_end < position; name_end++)
         if (!isalnum (s.buffer[name_end])
             && s.buffer[name_end] != '_'
@@ -536,8 +560,9 @@
       section_end = 0;
 
       /* Look for one or two characters within the brackets, the
-         first of which must be a digit and the second a letter. */
-      if (!isdigit (s.buffer[section + 1]))
+         first of which must be a non-zero digit and the second a letter. */
+      if (!isdigit (s.buffer[section + 1])
+          || s.buffer[section + 1] == '0')
         ;
       else if (!s.buffer[section + 2])
         ; /* end of buffer */




reply via email to

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