texinfo-commits
[Top][All Lists]
Advanced

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

[no subject]


From: Patrice Dumas
Date: Sat, 26 Feb 2022 19:13:28 -0500 (EST)

branch: master
commit 0112d6cbfee1c29911c4e7c672aeebc4608915ac
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sun Feb 27 01:13:14 2022 +0100

    Decode more inputs as perl character strings
    
    * tp/Texinfo/Convert/Converter.pm (determine_files_and_directory):
    do not encode setfilename, instead decode input file name.
    * tp/Texinfo/Convert/HTML.pm (html_image_file_location_name):
    do not return the encoded file name.
    * tp/Texinfo/Convert/HTML.pm (encoded_file_name): call
    encoded_file_name to encode file name just before calling
    output_files_open_out().
---
 ChangeLog                                          | 13 ++++++
 tp/Texinfo/Convert/Converter.pm                    | 20 ++++-----
 tp/Texinfo/Convert/HTML.pm                         | 48 +++++++++++++++-------
 tp/init/epub3.pm                                   |  2 +-
 .../non_ascii_command_line/Chapteur.html           |  2 +-
 .../res_parser/non_ascii_command_line/index.html   |  4 +-
 .../os\303\251_epub_package/EPUB/os\303\251.opf"   |  8 ++--
 .../EPUB/xhtml/nav_toc.xhtml"                      |  4 +-
 .../EPUB/xhtml/os\303\251.xhtml"                   |  2 +-
 .../META-INF/container.xml"                        |  2 +-
 tp/texi2any.pl                                     |  2 +-
 11 files changed, 66 insertions(+), 41 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 559f62c834..de2f4f5c52 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2022-02-27  Patrice Dumas  <pertusus@free.fr>
+
+       Decode more inputs as perl character strings
+
+       * tp/Texinfo/Convert/Converter.pm (determine_files_and_directory):
+       do not encode setfilename, instead decode input file name.
+       * tp/Texinfo/Convert/HTML.pm (html_image_file_location_name):
+       do not return the encoded file name.
+       * tp/Texinfo/Convert/HTML.pm (encoded_file_name): call
+       encoded_file_name to encode file name just before calling
+       output_files_open_out().
+
+
 2022-02-26  Gavin Smith  <gavinsmith0123@gmail.com>
 
        Attempt to fix copying image for epub3 test
diff --git a/tp/Texinfo/Convert/Converter.pm b/tp/Texinfo/Convert/Converter.pm
index 3225420010..195af8e1a5 100644
--- a/tp/Texinfo/Convert/Converter.pm
+++ b/tp/Texinfo/Convert/Converter.pm
@@ -26,7 +26,7 @@ use strict;
 use File::Basename;
 # for file names portability
 use File::Spec;
-use Encode;
+use Encode qw(decode);
 
 use Carp qw(cluck confess);
 
@@ -527,9 +527,13 @@ sub determine_files_and_directory($;$)
   # determine input file base name
   my $input_basefile;
   if (defined($self->{'parser_info'}->{'input_file_name'})) {
+    my $input_file_name = $self->{'parser_info'}->{'input_file_name'};
+    my $encoding = $self->get_conf('DATA_INPUT_ENCODING_NAME');
+    if (defined($encoding)) {
+      $input_file_name = decode($encoding, $input_file_name);
+    }
     my ($directories, $suffix);
-    ($input_basefile, $directories, $suffix)
-       = fileparse($self->{'parser_info'}->{'input_file_name'});
+    ($input_basefile, $directories, $suffix) = fileparse($input_file_name);
   } else {
     # This could happen if called on a piece of texinfo
     $input_basefile = '';
@@ -554,16 +558,6 @@ sub determine_files_and_directory($;$)
        = $self->{'global_commands'}->{'setfilename'}->{'extra'}->{'text_arg'};
   }
 
-  if ($setfilename) {
-    my $document_encoding;
-    my $ignored;
-    $document_encoding = $self->{'parser_info'}->{'input_perl_encoding'}
-      if ($self->{'parser_info'}
-            and defined($self->{'parser_info'}->{'input_perl_encoding'}));
-    ($setfilename, $ignored) = Texinfo::Common::encode_file_name(
-      $self, $setfilename, $document_encoding);
-  }
-
   my $input_basename_for_outfile = $input_basename;
   my $setfilename_for_outfile = $setfilename;
   # PREFIX overrides both setfilename and the input file base name
diff --git a/tp/Texinfo/Convert/HTML.pm b/tp/Texinfo/Convert/HTML.pm
index 2ef6df8c54..e8f4835791 100644
--- a/tp/Texinfo/Convert/HTML.pm
+++ b/tp/Texinfo/Convert/HTML.pm
@@ -282,7 +282,7 @@ sub html_image_file_location_name($$$$)
         # will be moved by the caller anyway.
         # If the file path found was to be used it should be decoded to perl
         # codepoints too.
-        $image_file = $file_name;
+        $image_file = $image_basefile.$extension;
         $image_extension = $extension;
         last;
       }
@@ -8919,12 +8919,16 @@ __("cannot use absolute path or URL `%s' for 
JS_WEBLABELS_FILE when generating w
   }
   my $license_file = File::Spec->catdir($destination_directory,
                                         $path);
+  # sequence of bytes
+  my ($licence_file_path, $path_encoding)
+     = $self->encoded_file_name($license_file);
   my $fh = Texinfo::Common::output_files_open_out(
-                 $self->output_files_information(), $self, $license_file);
+                 $self->output_files_information(), $self,
+                 $licence_file_path);
   if (defined($fh)) {
     print $fh $a;
     Texinfo::Common::output_files_register_closed(
-                  $self->output_files_information(), $license_file);
+                  $self->output_files_information(), $licence_file_path);
     if (!close ($fh)) {
       $self->document_error($self,
                sprintf(__("error on closing %s: %s"),
@@ -8963,9 +8967,11 @@ sub _default_format_frame_files($$)
   } else {
     $toc_frame_outfile = $toc_frame_file;
   }
-  
+  # sequence of bytes
+  my ($frame_file_path, $frame_path_encoding)
+     = $self->encoded_file_name($frame_outfile);
   my $frame_fh = Texinfo::Common::output_files_open_out(
-                     $self->output_files_information(), $self, $frame_outfile);
+                     $self->output_files_information(), $self, 
$frame_file_path);
   if (defined($frame_fh)) {
     my $doctype = $self->get_conf('FRAMESET_DOCTYPE');
     my $root_html_element_attributes = 
$self->_root_html_element_attributes_string();
@@ -8987,7 +8993,7 @@ $doctype
 EOT
 
     Texinfo::Common::output_files_register_closed(
-                  $self->output_files_information(), $frame_outfile);
+                  $self->output_files_information(), $frame_file_path);
     if (!close ($frame_fh)) {
       $self->document_error($self,
           sprintf(__("error on closing frame file %s: %s"),
@@ -9000,9 +9006,12 @@ EOT
                                   $frame_outfile, $!));
     return 0;
   }
-
+  # sequence of bytes
+  my ($toc_frame_path, $toc_frame_path_encoding)
+       = $self->encoded_file_name($toc_frame_outfile);
   my $toc_frame_fh = Texinfo::Common::output_files_open_out(
-                      $self->output_files_information(), $self, 
$toc_frame_outfile);
+                      $self->output_files_information(), $self,
+                      $toc_frame_path);
   if (defined($toc_frame_fh)) {
 
     # this is needed to collect CSS rules.
@@ -9020,7 +9029,7 @@ EOT
     $self->{'current_filename'} = undef;
 
     Texinfo::Common::output_files_register_closed(
-                  $self->output_files_information(), $toc_frame_outfile);
+                  $self->output_files_information(), $toc_frame_path);
     if (!close ($toc_frame_fh)) {
       $self->document_error($self,
             sprintf(__("error on closing TOC frame file %s: %s"),
@@ -9486,6 +9495,7 @@ sub output($$)
       or !defined($tree_units->[0]->{'structure'}->{'unit_filename'})) {
     # no page
     my $no_page_out_filepath;
+    my $encoded_no_page_out_filepath;
     if ($output_file ne '') {
       my $no_page_output_filename;
       if ($self->get_conf('SPLIT')) {
@@ -9500,8 +9510,12 @@ sub output($$)
         $no_page_out_filepath = $output_file;
         $no_page_output_filename = $output_filename;
       }
+      my $path_encoding;
+      ($encoded_no_page_out_filepath, $path_encoding)
+        = $self->encoded_file_name($no_page_out_filepath);
       $fh = Texinfo::Common::output_files_open_out(
-              $self->output_files_information(), $self, $no_page_out_filepath);
+              $self->output_files_information(), $self,
+              $encoded_no_page_out_filepath);
       if (!$fh) {
         $self->document_error($self,
               sprintf(__("could not open %s for writing: %s"),
@@ -9545,7 +9559,7 @@ sub output($$)
     # NOTE do not close STDOUT now to avoid a perl warning.
     if ($fh and $no_page_out_filepath ne '-') {
       Texinfo::Common::output_files_register_closed(
-                  $self->output_files_information(), $no_page_out_filepath);
+            $self->output_files_information(), $encoded_no_page_out_filepath);
       if (!close($fh)) {
         $self->document_error($self,
               sprintf(__("error on closing %s: %s"),
@@ -9602,9 +9616,11 @@ sub output($$)
       $self->{'file_counters'}->{$element_filename}--;
       if ($self->{'file_counters'}->{$element_filename} == 0) {
         my $file_element = $files{$element_filename}->{'first_element'};
+        my ($encoded_out_filepath, $path_encoding)
+          = $self->encoded_file_name($out_filepath);
         my $file_fh = Texinfo::Common::output_files_open_out(
                          $self->output_files_information(), $self,
-                         $out_filepath);
+                         $encoded_out_filepath);
         if (!$file_fh) {
           $self->document_error($self,
                sprintf(__("could not open %s for writing: %s"),
@@ -9623,7 +9639,7 @@ sub output($$)
         # NOTE do not close STDOUT here to avoid a perl warning
         if ($out_filepath ne '-') {
           Texinfo::Common::output_files_register_closed(
-             $self->output_files_information(), $out_filepath);
+             $self->output_files_information(), $encoded_out_filepath);
           if (!close($file_fh)) {
             $self->document_error($self,
                        sprintf(__("error on closing %s: %s"),
@@ -9711,9 +9727,11 @@ sub output($$)
         } else {
           $out_filename = $node_filename;
         }
+        my ($encoded_out_filename, $path_encoding)
+          = $self->encoded_file_name($out_filename);
         my $file_fh = Texinfo::Common::output_files_open_out(
                              $self->output_files_information(), $self,
-                             $out_filename);
+                             $encoded_out_filename);
         if (!$file_fh) {
          $self->document_error($self, sprintf(__(
                                     "could not open %s for writing: %s"),
@@ -9721,7 +9739,7 @@ sub output($$)
         } else {
           print $file_fh $redirection_page;
           Texinfo::Common::output_files_register_closed(
-                  $self->output_files_information(), $out_filename);
+                  $self->output_files_information(), $encoded_out_filename);
           if (!close ($file_fh)) {
             $self->document_error($self, sprintf(__(
                              "error on closing redirection node file %s: %s"),
diff --git a/tp/init/epub3.pm b/tp/init/epub3.pm
index 359d4ffca7..2d850f1991 100644
--- a/tp/init/epub3.pm
+++ b/tp/init/epub3.pm
@@ -505,7 +505,7 @@ EOT
   # <meta property="dcterms:modified">2012-03-05T12:47:00Z</meta>
   # also <dc:rights>
   my $opf_file = File::Spec->catfile($epub_destination_directory,
-                                        $epub_document_dir_name, $opf_filename 
);
+                                        $epub_document_dir_name, 
$opf_filename);
   my $opf_fh = Texinfo::Common::output_files_open_out(
                $self->output_files_information(), $self, $opf_file,
                undef, 'utf-8');
diff --git 
a/tp/tests/formatting/res_parser/non_ascii_command_line/Chapteur.html 
b/tp/tests/formatting/res_parser/non_ascii_command_line/Chapteur.html
index e7ee8b9acd..28445f9b5e 100644
--- a/tp/tests/formatting/res_parser/non_ascii_command_line/Chapteur.html
+++ b/tp/tests/formatting/res_parser/non_ascii_command_line/Chapteur.html
@@ -53,7 +53,7 @@ ul.mark-néni {list-style-type: "vàça"}
 <td valign="middle" align="left">[<a href="index.html" title="Cover (top) of 
document">Top</a>]</td>
 <td valign="middle" align="left">[Contents]</td>
 <td valign="middle" align="left">[Index]</td>
-<td valign="middle" align="left">[<a href="osé_abt.html#SEC_About" 
title="About (help)"> ? </a>]</td>
+<td valign="middle" align="left">[<a href="osé_abt.html#SEC_About" 
title="About (help)"> ? </a>]</td>
 </tr></table>
 <hr>
 <h1 class="chapter" id="Chapteur">1 Chapteùr</h1>
diff --git a/tp/tests/formatting/res_parser/non_ascii_command_line/index.html 
b/tp/tests/formatting/res_parser/non_ascii_command_line/index.html
index d6a7955d49..687a5a7831 100644
--- a/tp/tests/formatting/res_parser/non_ascii_command_line/index.html
+++ b/tp/tests/formatting/res_parser/non_ascii_command_line/index.html
@@ -47,7 +47,7 @@ ul.mark-néni {list-style-type: "vàça"}
 <td valign="middle" align="left"> &nbsp; </td>
 <td valign="middle" align="left">[Contents]</td>
 <td valign="middle" align="left">[Index]</td>
-<td valign="middle" align="left">[<a href="osé_abt.html#SEC_About" 
title="About (help)"> ? </a>]</td>
+<td valign="middle" align="left">[<a href="osé_abt.html#SEC_About" 
title="About (help)"> ? </a>]</td>
 </tr></table>
 <hr>
 <h1 class="top" id="Top-1">Tôp</h1>
@@ -60,7 +60,7 @@ ul.mark-néni {list-style-type: "vàça"}
 <td valign="middle" align="left"> &nbsp; </td>
 <td valign="middle" align="left">[Contents]</td>
 <td valign="middle" align="left">[Index]</td>
-<td valign="middle" align="left">[<a href="osé_abt.html#SEC_About" 
title="About (help)"> ? </a>]</td>
+<td valign="middle" align="left">[<a href="osé_abt.html#SEC_About" 
title="About (help)"> ? </a>]</td>
 </tr></table>
 <p>
   <span class="program-in-footer">This document was generated on <em 
class="emph">a sunny day</em> using <a class="uref" 
href="http://www.gnu.org/software/texinfo/";><em 
class="emph">texi2any</em></a>.</span>
diff --git 
"a/tp/tests/formatting/res_parser/non_ascii_test_epub/os\303\251_epub_package/EPUB/os\303\251.opf"
 
"b/tp/tests/formatting/res_parser/non_ascii_test_epub/os\303\251_epub_package/EPUB/os\303\251.opf"
index e9108c970a..661241a187 100644
--- 
"a/tp/tests/formatting/res_parser/non_ascii_test_epub/os\303\251_epub_package/EPUB/os\303\251.opf"
+++ 
"b/tp/tests/formatting/res_parser/non_ascii_test_epub/os\303\251_epub_package/EPUB/os\303\251.opf"
@@ -1,14 +1,14 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <package xmlns="http://www.idpf.org/2007/opf"; version="3.2" 
unique-identifier="texi-uid">
    <metadata xmlns:dc="http://purl.org/dc/elements/1.1/";>
-      <dc:identifier id="texi-uid">texinfo:osé</dc:identifier>
+      <dc:identifier id="texi-uid">texinfo:osé</dc:identifier>
       <dc:title>Tôp</dc:title>
    </metadata>
    <manifest>
       <item id="nav" properties="nav" media-type="application/xhtml+xml" 
href="xhtml/nav_toc.xhtml"/>
-      <item id="unit1" media-type="application/xhtml+xml" 
href="xhtml/osé.xhtml"/>
-      <item id="unit2" media-type="application/xhtml+xml" 
href="xhtml/osé.xhtml"/>
-      <item id="image1" media-type=" image/png" href="images/an_ïmage.png"/>
+      <item id="unit1" media-type="application/xhtml+xml" 
href="xhtml/osé.xhtml"/>
+      <item id="unit2" media-type="application/xhtml+xml" 
href="xhtml/osé.xhtml"/>
+      <item id="image1" media-type=" image/png" href="images/an_ïmage.png"/>
    </manifest>
    <spine>
       <itemref idref="unit1"/>
diff --git 
"a/tp/tests/formatting/res_parser/non_ascii_test_epub/os\303\251_epub_package/EPUB/xhtml/nav_toc.xhtml"
 
"b/tp/tests/formatting/res_parser/non_ascii_test_epub/os\303\251_epub_package/EPUB/xhtml/nav_toc.xhtml"
index 6ed3ca41e9..23a7c47783 100644
--- 
"a/tp/tests/formatting/res_parser/non_ascii_test_epub/os\303\251_epub_package/EPUB/xhtml/nav_toc.xhtml"
+++ 
"b/tp/tests/formatting/res_parser/non_ascii_test_epub/os\303\251_epub_package/EPUB/xhtml/nav_toc.xhtml"
@@ -9,8 +9,8 @@
 <h1>Table of contents</h1>
 
 <ol>
- <li><a href="osé.xhtml#Top">Tôp</a></li>
- <li><a href="osé.xhtml#Chapt_00eaur">1 Chapteùr</a></li>
+ <li><a href="osé.xhtml#Top">Tôp</a></li>
+ <li><a href="osé.xhtml#Chapt_00eaur">1 Chapteùr</a></li>
 </ol>
 </nav>
 </body>
diff --git 
"a/tp/tests/formatting/res_parser/non_ascii_test_epub/os\303\251_epub_package/EPUB/xhtml/os\303\251.xhtml"
 
"b/tp/tests/formatting/res_parser/non_ascii_test_epub/os\303\251_epub_package/EPUB/xhtml/os\303\251.xhtml"
index 1f32e0c774..93c0b7ded3 100644
--- 
"a/tp/tests/formatting/res_parser/non_ascii_test_epub/os\303\251_epub_package/EPUB/xhtml/os\303\251.xhtml"
+++ 
"b/tp/tests/formatting/res_parser/non_ascii_test_epub/os\303\251_epub_package/EPUB/xhtml/os\303\251.xhtml"
@@ -35,7 +35,7 @@ span.program-in-footer {font-size: smaller}
 </p>
 <p>In included téxt.
 </p>
-<img class="image" src="../images/an_ïmage.png" alt="öld"/>
+<img class="image" src="../images/an_ïmage.png" alt="öld"/>
 
 <img class="image" src="../images/dîrectory/imàge.êxt" alt="âlt"/>
 
diff --git 
"a/tp/tests/formatting/res_parser/non_ascii_test_epub/os\303\251_epub_package/META-INF/container.xml"
 
"b/tp/tests/formatting/res_parser/non_ascii_test_epub/os\303\251_epub_package/META-INF/container.xml"
index b3efc6cc13..623c34a8f0 100644
--- 
"a/tp/tests/formatting/res_parser/non_ascii_test_epub/os\303\251_epub_package/META-INF/container.xml"
+++ 
"b/tp/tests/formatting/res_parser/non_ascii_test_epub/os\303\251_epub_package/META-INF/container.xml"
@@ -1,7 +1,7 @@
 <?xml version="1.0"?>
 <container version="1.0" 
xmlns="urn:oasis:names:tc:opendocument:xmlns:container">
     <rootfiles>
-        <rootfile full-path="EPUB/osé.opf"
+        <rootfile full-path="EPUB/osé.opf"
             media-type="application/oebps-package+xml" />      
     </rootfiles>
 </container>
diff --git a/tp/texi2any.pl b/tp/texi2any.pl
index 8be0945de9..3fc5a8ea49 100755
--- a/tp/texi2any.pl
+++ b/tp/texi2any.pl
@@ -916,7 +916,7 @@ There is NO WARRANTY, to the extent permitted by law.\n"), 
"2021");
       set_from_cmdline($var, undef);
       $var = 'SUBDIR';
     }
-    set_from_cmdline($var, $_[1]);
+    set_from_cmdline($var, _decode_input($_[1]));
     push @texi2dvi_args, '-o', $_[1];
   },
  'no-validate|no-pointer-validate' => sub {



reply via email to

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