[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[no subject]
From: |
Gavin D. Smith |
Date: |
Sat, 12 Nov 2022 17:25:45 -0500 (EST) |
branch: release/7.0
commit 15ef3457ed1eefc2623c951da2c0666e85bdef9c
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sat Nov 12 21:14:11 2022 +0000
* tp/Texinfo/Convert/HTML.pm: avoid formatting when contents
is not set, avoiding a crash with empty @titlefont as title.
* tp/Texinfo/Convert/Plaintext.pm (_convert): do not format
author if there is no contents, this cannot happen for now but is more
robust.
---
ChangeLog | 9 ++
tp/Texinfo/Convert/HTML.pm | 34 +++++---
tp/Texinfo/Convert/Plaintext.pm | 15 ++--
tp/t/html_tests.t | 4 +
tp/t/results/html_tests/empty_titlefont.pl | 95 ++++++++++++++++++++++
tp/t/results/preformatted/titlefont_in_example.pl | 17 +++-
.../sectioning/unnumbered_before_top_node.pl | 16 +++-
7 files changed, 169 insertions(+), 21 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index e5b27215ff..3b3e0392eb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2022-11-08 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/Convert/HTML.pm: avoid formatting when contents
+ is not set, avoiding a crash with empty @titlefont as title.
+
+ * tp/Texinfo/Convert/Plaintext.pm (_convert): do not format
+ author if there is no contents, this cannot happen for now but is more
+ robust.
+
2022-11-08 Patrice Dumas <pertusus@free.fr>
* tp/Texinfo/Convert/Info.pm (_convert): avoid crashes in case
diff --git a/tp/Texinfo/Convert/HTML.pm b/tp/Texinfo/Convert/HTML.pm
index 4be25be7a5..80683cd31f 100644
--- a/tp/Texinfo/Convert/HTML.pm
+++ b/tp/Texinfo/Convert/HTML.pm
@@ -2729,9 +2729,12 @@ sub _convert_explained_command($$$$)
my $with_explanation;
my $explanation_result;
my $explanation_string;
- my $normalized_type
- = Texinfo::Convert::NodeNameNormalization::normalize_node(
- {'contents' => $command->{'args'}->[0]->{'contents'}});
+ my $normalized_type = '';
+ if ($command->{'args'}->[0]
+ and $command->{'args'}->[0]->{'contents'}) {
+ $normalized_type = Texinfo::Convert::NodeNameNormalization::normalize_node(
+ {'contents' => $command->{'args'}->[0]->{'contents'}});
+ }
my $explained_commands
= $self->shared_conversion_state('explained_commands', {});
@@ -4480,7 +4483,8 @@ sub _convert_float_command($$$$$)
$prepended_text = '';
}
my $caption_text = '';
- if ($caption) {
+ if ($caption and $caption->{'args'}->[0]
+ and $caption->{'args'}->[0]->{'contents'}) {
$caption_text = $self->convert_tree_new_formatting_context(
{'contents' => $caption->{'args'}->[0]->{'contents'}},
'float caption');
@@ -4565,10 +4569,13 @@ sub _convert_quotation_command($$$$$)
# FIXME there is no easy way to mark with a class the @author
# @-command. Add a span or a div (@center is in a div)?
foreach my $author (@{$command->{'extra'}->{'authors'}}) {
- my $centered_author = $self->gdt("\@center --- \@emph{{author}}\n",
- {'author' => $author->{'args'}->[0]->{'contents'}});
- $centered_author->{'parent'} = $command;
- $attribution .= $self->convert_tree($centered_author, 'convert quotation
author');
+ if ($author->{'args'}->[0]
+ and $author->{'args'}->[0]->{'contents'}) {
+ my $centered_author = $self->gdt("\@center --- \@emph{{author}}\n",
+ {'author' => $author->{'args'}->[0]->{'contents'}});
+ $centered_author->{'parent'} = $command;
+ $attribution .= $self->convert_tree($centered_author, 'convert
quotation author');
+ }
}
}
@@ -5806,6 +5813,7 @@ sub _convert_row_type($$$$) {
if ($content =~ /\S/) {
my $result = '<tr>' . $content . '</tr>';
if ($element->{'contents'}
+ and scalar(@{$element->{'contents'}})
and $element->{'contents'}->[0]->{'cmdname'} ne 'headitem') {
# if headitem, end of line added in _convert_multitable_head_type
$result .= "\n";
@@ -5906,6 +5914,9 @@ sub _convert_menu_entry_type($$$)
and $args[0]->{'type'} eq 'menu_entry_description');
my $arg = shift @args;
if ($arg->{'type'} and $arg->{'type'} eq 'menu_entry_node') {
+ # $arg->{'contents'} seems to always be defined. If it is
+ # not the case, it should not be an issue as an undefined
+ # 'contents' is ignored.
my $name = $self->convert_tree(
{'type' => '_code', 'contents' => $arg->{'contents'}},
"menu_arg menu_entry_node preformatted [$i]");
@@ -9916,6 +9927,7 @@ sub output($$)
if (!$fulltitle and $self->{'global_commands'}->{'titlefont'}
and $self->{'global_commands'}->{'titlefont'}->[0]->{'args'}
and
defined($self->{'global_commands'}->{'titlefont'}->[0]->{'args'}->[0])
+ and $self->{'global_commands'}->{'titlefont'}->[0]->{'contents'}
and
@{$self->{'global_commands'}->{'titlefont'}->[0]->{'args'}->[0]->{'contents'}})
{
$fulltitle = $self->{'global_commands'}->{'titlefont'}->[0];
}
@@ -9923,8 +9935,10 @@ sub output($$)
foreach my $simpletitle_command ('settitle', 'shorttitlepage') {
if ($self->{'global_commands'}->{$simpletitle_command}) {
my $command = $self->{'global_commands'}->{$simpletitle_command};
- next if ($command->{'extra'}
- and $command->{'extra'}->{'missing_argument'});
+ next if (!$command->{'args'}
+ or !$command->{'args'}->[0]->{'contents'}
+ or ($command->{'extra'}
+ and $command->{'extra'}->{'missing_argument'}));
$self->{'simpletitle_tree'} =
{'contents' => $command->{'args'}->[0]->{'contents'}};
$self->{'simpletitle_command_name'} = $simpletitle_command;
diff --git a/tp/Texinfo/Convert/Plaintext.pm b/tp/Texinfo/Convert/Plaintext.pm
index 27ae9d5433..cc85c60361 100644
--- a/tp/Texinfo/Convert/Plaintext.pm
+++ b/tp/Texinfo/Convert/Plaintext.pm
@@ -3467,13 +3467,18 @@ sub _convert($$)
$result .= _convert($self, $tree);
}
}
- } elsif (($command eq 'quotation'
+ } elsif (($command eq 'quotation'
or $command eq 'smallquotation')
and $element->{'extra'} and $element->{'extra'}->{'authors'}) {
foreach my $author (@{$element->{'extra'}->{'authors'}}) {
- $result .= _convert($self,
- $self->gdt("\@center --- \@emph{{author}}\n",
- {'author' => $author->{'args'}->[0]->{'contents'}}));
+ # this cannot happen as this should be caugth by 'missing_argument'
+ # but it is more robust to check anyway
+ if ($author->{'args'}->[0]
+ and $author->{'args'}->[0]->{'contents'}) {
+ $result .= _convert($self,
+ $self->gdt("\@center --- \@emph{{author}}\n",
+ {'author' => $author->{'args'}->[0]->{'contents'}}));
+ }
}
} elsif (($command eq 'multitable')) {
$self->{'document_context'}->[-1]->{'in_multitable'}--;
@@ -3499,7 +3504,7 @@ sub _convert($$)
}
}
}
-
+
# close the contexts and register the cells
if ($self->{'preformatted_context_commands'}->{$command}
or $command eq 'float') {
diff --git a/tp/t/html_tests.t b/tp/t/html_tests.t
index e7cd6666b6..b0c0863f54 100644
--- a/tp/t/html_tests.t
+++ b/tp/t/html_tests.t
@@ -552,6 +552,10 @@ In top.
@uref{http://example.com/acc_@"a@ogonek{a}}
'],
+['empty_titlefont',
+'
+@titlefont{}
+'],
);
my $test_accents_sc_no_brace_commands_quotes = '@u{--a}
diff --git a/tp/t/results/html_tests/empty_titlefont.pl
b/tp/t/results/html_tests/empty_titlefont.pl
new file mode 100644
index 0000000000..97765bf422
--- /dev/null
+++ b/tp/t/results/html_tests/empty_titlefont.pl
@@ -0,0 +1,95 @@
+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{'empty_titlefont'} = {
+ 'contents' => [
+ {
+ 'contents' => [
+ {
+ 'text' => '
+',
+ 'type' => 'empty_line'
+ },
+ {
+ 'args' => [
+ {
+ 'type' => 'brace_command_arg'
+ }
+ ],
+ 'cmdname' => 'titlefont',
+ 'source_info' => {
+ 'file_name' => '',
+ 'line_nr' => 2,
+ 'macro' => ''
+ }
+ },
+ {
+ 'text' => '
+'
+ }
+ ],
+ 'type' => 'before_node_section'
+ }
+ ],
+ 'type' => 'document_root'
+};
+
+$result_texis{'empty_titlefont'} = '
+@titlefont{}
+';
+
+
+$result_texts{'empty_titlefont'} = '
+
+';
+
+$result_errors{'empty_titlefont'} = [];
+
+
+$result_floats{'empty_titlefont'} = {};
+
+
+
+$result_converted{'html'}->{'empty_titlefont'} = '<!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>Untitled Document</title>
+
+<meta name="description" content="Untitled Document">
+<meta name="keywords" content="Untitled Document">
+<meta name="resource-type" content="document">
+<meta name="distribution" content="global">
+<meta name="viewport" content="width=device-width,initial-scale=1">
+
+
+
+</head>
+
+<body lang="en">
+
+
+
+
+
+</body>
+</html>
+';
+
+$result_converted_errors{'html'}->{'empty_titlefont'} = [
+ {
+ 'error_line' => 'warning: must specify a title with a title command or @top
+',
+ 'file_name' => 'empty_titlefont.texi',
+ 'text' => 'must specify a title with a title command or @top',
+ 'type' => 'warning'
+ }
+];
+
+
+1;
diff --git a/tp/t/results/preformatted/titlefont_in_example.pl
b/tp/t/results/preformatted/titlefont_in_example.pl
index d35b4e7fdc..9b97554876 100644
--- a/tp/t/results/preformatted/titlefont_in_example.pl
+++ b/tp/t/results/preformatted/titlefont_in_example.pl
@@ -121,10 +121,10 @@ $result_converted{'html'}->{'titlefont_in_example'} =
'<!DOCTYPE html>
<!-- Created by texinfo, http://www.gnu.org/software/texinfo/ -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
-<title>Title</title>
+<title>Untitled Document</title>
-<meta name="description" content="Title">
-<meta name="keywords" content="Title">
+<meta name="description" content="Untitled Document">
+<meta name="keywords" content="Untitled Document">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="viewport" content="width=device-width,initial-scale=1">
@@ -151,6 +151,17 @@ Text.
</html>
';
+$result_converted_errors{'html'}->{'titlefont_in_example'} = [
+ {
+ 'error_line' => 'warning: must specify a title with a title command or @top
+',
+ 'file_name' => 'titlefont_in_example.texi',
+ 'text' => 'must specify a title with a title command or @top',
+ 'type' => 'warning'
+ }
+];
+
+
$result_converted{'docbook'}->{'titlefont_in_example'} = 'Title<screen>
Text.
diff --git a/tp/t/results/sectioning/unnumbered_before_top_node.pl
b/tp/t/results/sectioning/unnumbered_before_top_node.pl
index 8f7800a166..c051159adc 100644
--- a/tp/t/results/sectioning/unnumbered_before_top_node.pl
+++ b/tp/t/results/sectioning/unnumbered_before_top_node.pl
@@ -298,10 +298,10 @@ $result_converted{'html'}->{'unnumbered_before_top_node'}
= '<!DOCTYPE html>
<!-- Created by texinfo, http://www.gnu.org/software/texinfo/ -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
-<title>Title titlefont</title>
+<title>Untitled Document</title>
-<meta name="description" content="Title titlefont">
-<meta name="keywords" content="Title titlefont">
+<meta name="description" content="Untitled Document">
+<meta name="keywords" content="Untitled Document">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="viewport" content="width=device-width,initial-scale=1">
@@ -327,6 +327,16 @@ $result_converted{'html'}->{'unnumbered_before_top_node'}
= '<!DOCTYPE html>
</html>
';
+$result_converted_errors{'html'}->{'unnumbered_before_top_node'} = [
+ {
+ 'error_line' => 'warning: must specify a title with a title command or @top
+',
+ 'text' => 'must specify a title with a title command or @top',
+ 'type' => 'warning'
+ }
+];
+
+
$result_converted{'docbook'}->{'unnumbered_before_top_node'} = '<chapter
label="">
<title>before nodes</title>
- release/7.0 updated (fd06f6898a -> 556525720b), Gavin D. Smith, 2022/11/12
- [no subject], Gavin D. Smith, 2022/11/12
- [no subject],
Gavin D. Smith <=
- [no subject], Gavin D. Smith, 2022/11/12
- [no subject], Gavin D. Smith, 2022/11/12
- [no subject], Gavin D. Smith, 2022/11/12
- [no subject], Gavin D. Smith, 2022/11/12
- [no subject], Gavin D. Smith, 2022/11/12
- [no subject], Gavin D. Smith, 2022/11/12