texinfo-commits
[Top][All Lists]
Advanced

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

branch master updated: * tp/Texinfo/Convert/HTML.pm (_convert_xref_comma


From: Patrice Dumas
Subject: branch master updated: * tp/Texinfo/Convert/HTML.pm (_convert_xref_commands), tp/Texinfo/XS/convert/convert_html.c (convert_xref_commands): avoid an infinite recursion going through ref to node on sectioning command line and ref to sectioning command on node line, in case USE_NODES is 0.
Date: Wed, 04 Sep 2024 15:32:46 -0400

This is an automated email from the git hooks/post-receive script.

pertusus pushed a commit to branch master
in repository texinfo.

The following commit(s) were added to refs/heads/master by this push:
     new 1c34d113c9 * tp/Texinfo/Convert/HTML.pm (_convert_xref_commands), 
tp/Texinfo/XS/convert/convert_html.c (convert_xref_commands): avoid an infinite 
recursion going through ref to node on sectioning command line and ref to 
sectioning command on node line, in case USE_NODES is 0.
1c34d113c9 is described below

commit 1c34d113c909b648aeeed30283321db1ac95c8be
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Wed Sep 4 21:32:46 2024 +0200

    * tp/Texinfo/Convert/HTML.pm (_convert_xref_commands),
    tp/Texinfo/XS/convert/convert_html.c (convert_xref_commands): avoid an
    infinite recursion going through ref to node on sectioning command
    line and ref to sectioning command on node line, in case USE_NODES is
    0.
    
    * tp/Makefile.tres, tp/t/30sectioning.t
    (double_recursive_self_section_node_reference_no_use_node): test
    double recursive self section node reference with USE_NODES=0.
---
 ChangeLog                                          |  12 +
 tp/Makefile.tres                                   |   1 +
 tp/Texinfo/Convert/HTML.pm                         |   7 +-
 tp/Texinfo/XS/convert/convert_html.c               |   7 +-
 tp/t/30sectioning.t                                |   9 +
 ...sive_self_section_node_reference_no_use_node.pl | 449 +++++++++++++++++++++
 6 files changed, 483 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 3cc27bfd45..f19b146750 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2024-09-04  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/Convert/HTML.pm (_convert_xref_commands),
+       tp/Texinfo/XS/convert/convert_html.c (convert_xref_commands): avoid an
+       infinite recursion going through ref to node on sectioning command
+       line and ref to sectioning command on node line, in case USE_NODES is
+       0.
+
+       * tp/Makefile.tres, tp/t/30sectioning.t
+       (double_recursive_self_section_node_reference_no_use_node): test
+       double recursive self section node reference with USE_NODES=0.
+
 2024-09-04  Patrice Dumas  <pertusus@free.fr>
 
        * tp/maintain/all_tests.sh: use $srcdir, adapt for out of source
diff --git a/tp/Makefile.tres b/tp/Makefile.tres
index 7a593b7a4b..a379462266 100644
--- a/tp/Makefile.tres
+++ b/tp/Makefile.tres
@@ -1902,6 +1902,7 @@ test_files_generated_list = 
$(test_tap_files_generated_list) \
   t/results/sectioning/double_node_anchor_float.pl \
   t/results/sectioning/double_part.pl \
   t/results/sectioning/double_recursive_self_section_node_reference.pl \
+  
t/results/sectioning/double_recursive_self_section_node_reference_no_use_node.pl
 \
   t/results/sectioning/double_recursive_self_section_reference.pl \
   t/results/sectioning/double_top.pl \
   t/results/sectioning/double_top_in_menu.pl \
diff --git a/tp/Texinfo/Convert/HTML.pm b/tp/Texinfo/Convert/HTML.pm
index 214e9984b1..bb26474d7a 100644
--- a/tp/Texinfo/Convert/HTML.pm
+++ b/tp/Texinfo/Convert/HTML.pm
@@ -6143,7 +6143,12 @@ sub _convert_xref_commands($$$$)
         }
       } elsif (!$self->get_conf('XREF_USE_NODE_NAME_ARG')
                and (defined($self->get_conf('XREF_USE_NODE_NAME_ARG'))
-                    or !in_preformatted_context($self))) {
+                    or !in_preformatted_context($self))
+         # this condition avoids infinite recursions, example with
+         # USE_NODES=0 and node referring to the section and section referring
+         # to the node
+              and not _command_is_in_referred_command_stack($self,
+                                                            $target_root)) {
         $name = $self->command_text($target_root, 'text_nonumber');
         #die "$target_root $target_root->{'normalized'}" if (!defined($name));
       } elsif (defined($args->[0]->{'monospace'})) {
diff --git a/tp/Texinfo/XS/convert/convert_html.c 
b/tp/Texinfo/XS/convert/convert_html.c
index 6f7c8757f9..fc18f5ca20 100644
--- a/tp/Texinfo/XS/convert/convert_html.c
+++ b/tp/Texinfo/XS/convert/convert_html.c
@@ -12216,7 +12216,12 @@ convert_xref_commands (CONVERTER *self, const enum 
command_id cmd,
             }
           else if (self->conf->XREF_USE_NODE_NAME_ARG.o.integer <= 0
                    && (self->conf->XREF_USE_NODE_NAME_ARG.o.integer == 0
-                       || !html_in_preformatted_context (self)))
+                       || !html_in_preformatted_context (self))
+        /* this condition avoids infinite recursions, example with
+           USE_NODES=0 and node referring to the section and section referring
+           to the node */
+                   && !command_is_in_referred_command_stack (
+                         &self->referred_command_stack, target_root, 0))
             {
               name = html_command_text (self, target_root, HTT_text_nonumber);
             }
diff --git a/tp/t/30sectioning.t b/tp/t/30sectioning.t
index 0c4f1e4459..f6cefb8fd0 100644
--- a/tp/t/30sectioning.t
+++ b/tp/t/30sectioning.t
@@ -353,6 +353,15 @@ in chap
 
 @node to @ref{node1}
 '],
+['double_recursive_self_section_node_reference_no_use_node',
+'@node Top
+@top top
+
+@node node1
+@chapter @ref{to node1}
+
+@node to @ref{node1}
+', {}, {'USE_NODES' => 0},]
 );
 
 
diff --git 
a/tp/t/results/sectioning/double_recursive_self_section_node_reference_no_use_node.pl
 
b/tp/t/results/sectioning/double_recursive_self_section_node_reference_no_use_node.pl
new file mode 100644
index 0000000000..0794a11b55
--- /dev/null
+++ 
b/tp/t/results/sectioning/double_recursive_self_section_node_reference_no_use_node.pl
@@ -0,0 +1,449 @@
+use vars qw(%result_texis %result_texts %result_trees %result_errors 
+   %result_indices %result_sectioning %result_nodes %result_menus
+   %result_floats %result_converted %result_converted_errors 
+   %result_elements %result_directions_text %result_indices_sort_strings);
+
+use utf8;
+
+$result_trees{'double_recursive_self_section_node_reference_no_use_node'} = {
+  'contents' => [
+    {
+      'contents' => [
+        {
+          'type' => 'preamble_before_content'
+        }
+      ],
+      'type' => 'before_node_section'
+    },
+    {
+      'args' => [
+        {
+          'contents' => [
+            {
+              'text' => 'Top'
+            }
+          ],
+          'info' => {
+            'spaces_after_argument' => {
+              'text' => '
+'
+            }
+          },
+          'type' => 'line_arg'
+        }
+      ],
+      'cmdname' => 'node',
+      'extra' => {
+        'is_target' => 1,
+        'normalized' => 'Top'
+      },
+      'info' => {
+        'spaces_before_argument' => {
+          'text' => ' '
+        }
+      },
+      'source_info' => {
+        'line_nr' => 1
+      }
+    },
+    {
+      'args' => [
+        {
+          'contents' => [
+            {
+              'text' => 'top'
+            }
+          ],
+          'info' => {
+            'spaces_after_argument' => {
+              'text' => '
+'
+            }
+          },
+          'type' => 'line_arg'
+        }
+      ],
+      'cmdname' => 'top',
+      'contents' => [
+        {
+          'text' => '
+',
+          'type' => 'empty_line'
+        }
+      ],
+      'extra' => {},
+      'info' => {
+        'spaces_before_argument' => {
+          'text' => ' '
+        }
+      },
+      'source_info' => {
+        'line_nr' => 2
+      }
+    },
+    {
+      'args' => [
+        {
+          'contents' => [
+            {
+              'text' => 'node1'
+            }
+          ],
+          'info' => {
+            'spaces_after_argument' => {
+              'text' => '
+'
+            }
+          },
+          'type' => 'line_arg'
+        }
+      ],
+      'cmdname' => 'node',
+      'extra' => {
+        'is_target' => 1,
+        'normalized' => 'node1'
+      },
+      'info' => {
+        'spaces_before_argument' => {
+          'text' => ' '
+        }
+      },
+      'source_info' => {
+        'line_nr' => 4
+      }
+    },
+    {
+      'args' => [
+        {
+          'contents' => [
+            {
+              'args' => [
+                {
+                  'contents' => [
+                    {
+                      'text' => 'to node1'
+                    }
+                  ],
+                  'extra' => {
+                    'node_content' => {
+                      'contents' => [
+                        {}
+                      ]
+                    },
+                    'normalized' => 'to-node1'
+                  },
+                  'type' => 'brace_command_arg'
+                }
+              ],
+              'cmdname' => 'ref',
+              'source_info' => {
+                'line_nr' => 5
+              }
+            }
+          ],
+          'info' => {
+            'spaces_after_argument' => {
+              'text' => '
+'
+            }
+          },
+          'type' => 'line_arg'
+        }
+      ],
+      'cmdname' => 'chapter',
+      'contents' => [
+        {
+          'text' => '
+',
+          'type' => 'empty_line'
+        }
+      ],
+      'extra' => {
+        'section_number' => '1'
+      },
+      'info' => {
+        'spaces_before_argument' => {
+          'text' => ' '
+        }
+      },
+      'source_info' => {
+        'line_nr' => 5
+      }
+    },
+    {
+      'args' => [
+        {
+          'contents' => [
+            {
+              'text' => 'to '
+            },
+            {
+              'args' => [
+                {
+                  'contents' => [
+                    {
+                      'text' => 'node1'
+                    }
+                  ],
+                  'extra' => {
+                    'node_content' => {
+                      'contents' => [
+                        {}
+                      ]
+                    },
+                    'normalized' => 'node1'
+                  },
+                  'type' => 'brace_command_arg'
+                }
+              ],
+              'cmdname' => 'ref',
+              'source_info' => {
+                'line_nr' => 7
+              }
+            }
+          ],
+          'info' => {
+            'spaces_after_argument' => {
+              'text' => '
+'
+            }
+          },
+          'type' => 'line_arg'
+        }
+      ],
+      'cmdname' => 'node',
+      'extra' => {
+        'is_target' => 1,
+        'normalized' => 'to-node1'
+      },
+      'info' => {
+        'spaces_before_argument' => {
+          'text' => ' '
+        }
+      },
+      'source_info' => {
+        'line_nr' => 7
+      }
+    }
+  ],
+  'type' => 'document_root'
+};
+$result_trees{'double_recursive_self_section_node_reference_no_use_node'}{'contents'}[4]{'args'}[0]{'contents'}[0]{'args'}[0]{'extra'}{'node_content'}{'contents'}[0]
 = 
$result_trees{'double_recursive_self_section_node_reference_no_use_node'}{'contents'}[4]{'args'}[0]{'contents'}[0]{'args'}[0]{'contents'}[0];
+$result_trees{'double_recursive_self_section_node_reference_no_use_node'}{'contents'}[5]{'args'}[0]{'contents'}[1]{'args'}[0]{'extra'}{'node_content'}{'contents'}[0]
 = 
$result_trees{'double_recursive_self_section_node_reference_no_use_node'}{'contents'}[5]{'args'}[0]{'contents'}[1]{'args'}[0]{'contents'}[0];
+
+$result_texis{'double_recursive_self_section_node_reference_no_use_node'} = 
'@node Top
+@top top
+
+@node node1
+@chapter @ref{to node1}
+
+@node to @ref{node1}
+';
+
+
+$result_texts{'double_recursive_self_section_node_reference_no_use_node'} = 
'top
+***
+
+1 to node1
+**********
+
+';
+
+$result_sectioning{'double_recursive_self_section_node_reference_no_use_node'} 
= {
+  'extra' => {
+    'section_childs' => [
+      {
+        'cmdname' => 'top',
+        'extra' => {
+          'associated_node' => {
+            'cmdname' => 'node',
+            'extra' => {
+              'normalized' => 'Top'
+            }
+          },
+          'section_childs' => [
+            {
+              'cmdname' => 'chapter',
+              'extra' => {
+                'associated_node' => {
+                  'cmdname' => 'node',
+                  'extra' => {
+                    'normalized' => 'node1'
+                  }
+                },
+                'section_directions' => {
+                  'up' => {}
+                },
+                'section_level' => 1,
+                'section_number' => '1',
+                'toplevel_directions' => {
+                  'prev' => {},
+                  'up' => {}
+                }
+              }
+            }
+          ],
+          'section_level' => 0,
+          'sectioning_root' => {},
+          'toplevel_directions' => {}
+        }
+      }
+    ],
+    'section_level' => -1
+  }
+};
+$result_sectioning{'double_recursive_self_section_node_reference_no_use_node'}{'extra'}{'section_childs'}[0]{'extra'}{'section_childs'}[0]{'extra'}{'section_directions'}{'up'}
 = 
$result_sectioning{'double_recursive_self_section_node_reference_no_use_node'}{'extra'}{'section_childs'}[0];
+$result_sectioning{'double_recursive_self_section_node_reference_no_use_node'}{'extra'}{'section_childs'}[0]{'extra'}{'section_childs'}[0]{'extra'}{'toplevel_directions'}{'prev'}
 = 
$result_sectioning{'double_recursive_self_section_node_reference_no_use_node'}{'extra'}{'section_childs'}[0];
+$result_sectioning{'double_recursive_self_section_node_reference_no_use_node'}{'extra'}{'section_childs'}[0]{'extra'}{'section_childs'}[0]{'extra'}{'toplevel_directions'}{'up'}
 = 
$result_sectioning{'double_recursive_self_section_node_reference_no_use_node'}{'extra'}{'section_childs'}[0];
+$result_sectioning{'double_recursive_self_section_node_reference_no_use_node'}{'extra'}{'section_childs'}[0]{'extra'}{'sectioning_root'}
 = 
$result_sectioning{'double_recursive_self_section_node_reference_no_use_node'};
+
+$result_nodes{'double_recursive_self_section_node_reference_no_use_node'} = [
+  {
+    'cmdname' => 'node',
+    'extra' => {
+      'associated_section' => {
+        'cmdname' => 'top',
+        'extra' => {}
+      },
+      'node_directions' => {
+        'next' => {
+          'cmdname' => 'node',
+          'extra' => {
+            'associated_section' => {
+              'cmdname' => 'chapter',
+              'extra' => {
+                'section_number' => '1'
+              }
+            },
+            'node_directions' => {
+              'prev' => {},
+              'up' => {}
+            },
+            'normalized' => 'node1'
+          }
+        }
+      },
+      'normalized' => 'Top'
+    }
+  },
+  {},
+  {
+    'cmdname' => 'node',
+    'extra' => {
+      'normalized' => 'to-node1'
+    }
+  }
+];
+$result_nodes{'double_recursive_self_section_node_reference_no_use_node'}[0]{'extra'}{'node_directions'}{'next'}{'extra'}{'node_directions'}{'prev'}
 = $result_nodes{'double_recursive_self_section_node_reference_no_use_node'}[0];
+$result_nodes{'double_recursive_self_section_node_reference_no_use_node'}[0]{'extra'}{'node_directions'}{'next'}{'extra'}{'node_directions'}{'up'}
 = $result_nodes{'double_recursive_self_section_node_reference_no_use_node'}[0];
+$result_nodes{'double_recursive_self_section_node_reference_no_use_node'}[1] = 
$result_nodes{'double_recursive_self_section_node_reference_no_use_node'}[0]{'extra'}{'node_directions'}{'next'};
+
+$result_menus{'double_recursive_self_section_node_reference_no_use_node'} = [
+  {
+    'extra' => {
+      'normalized' => 'Top'
+    }
+  },
+  {
+    'extra' => {
+      'normalized' => 'node1'
+    }
+  },
+  {
+    'extra' => {
+      'normalized' => 'to-node1'
+    }
+  }
+];
+
+$result_errors{'double_recursive_self_section_node_reference_no_use_node'} = [
+  {
+    'error_line' => 'warning: @ref should not appear on @node line
+',
+    'line_nr' => 7,
+    'text' => '@ref should not appear on @node line',
+    'type' => 'warning'
+  },
+  {
+    'error_line' => 'warning: @ref to `to node1\', different from node name 
`to @ref{node1}\'
+',
+    'line_nr' => 5,
+    'text' => '@ref to `to node1\', different from node name `to 
@ref{node1}\'',
+    'type' => 'warning'
+  }
+];
+
+
+$result_floats{'double_recursive_self_section_node_reference_no_use_node'} = 
{};
+
+
+
+$result_converted{'plaintext'}->{'double_recursive_self_section_node_reference_no_use_node'}
 = 'top
+***
+
+1 *note to *note node1::::
+**************************
+
+';
+
+$result_converted_errors{'plaintext'}->{'double_recursive_self_section_node_reference_no_use_node'}
 = [
+  {
+    'error_line' => 'warning: @ref node name should not contain `:\'
+',
+    'line_nr' => 5,
+    'text' => '@ref node name should not contain `:\'',
+    'type' => 'warning'
+  }
+];
+
+
+
+$result_converted{'html'}->{'double_recursive_self_section_node_reference_no_use_node'}
 = '<!DOCTYPE html>
+<html>
+<!-- Created by texinfo, http://www.gnu.org/software/texinfo/ -->
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+<title>top</title>
+
+<meta name="description" content="top">
+<meta name="keywords" content="top">
+<meta name="resource-type" content="document">
+<meta name="distribution" content="global">
+<meta name="viewport" content="width=device-width,initial-scale=1">
+
+<link href="#Top" rel="start" title="top">
+<style type="text/css">
+<!--
+a.copiable-link {visibility: hidden; text-decoration: none; line-height: 0em}
+span:hover a.copiable-link {visibility: visible}
+-->
+</style>
+
+
+</head>
+
+<body lang="en">
+<div class="top-level-extent" id="Top">
+<h1 class="top" id="top"><span>top<a class="copiable-link" href="#top"> 
&para;</a></span></h1>
+
+<ul class="mini-toc">
+<li><a href="#node1" accesskey="1"><a class="ref" href="#to-node1">to <a 
class="ref" href="#node1"><a class="ref" href="#to-node1">to 
node1</a></a></a></a></li>
+</ul>
+<hr>
+<div class="chapter-level-extent" id="node1">
+<div class="nav-panel">
+<p>
+ Up : <a href="#Top" accesskey="u" rel="up">top</a> &nbsp; </p>
+</div>
+<h2 class="chapter" id="to-node1-1"><span>1 <a class="ref" href="#to-node1">to 
<a class="ref" href="#node1"><a class="ref" href="#to-node1">to 
node1</a></a></a><a class="copiable-link" href="#to-node1-1"> 
&para;</a></span></h2>
+
+<a class="node" id="to-node1"></a></div>
+</div>
+
+
+
+</body>
+</html>
+';
+
+1;



reply via email to

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