Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

man: fix po4a's incorrect handling of \& in doblequotes #540

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions lib/Locale/Po4a/Man.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1674,25 +1674,25 @@ sub splitargs {
# anymore. Let's play safe.
$arguments =~ s/\\ /$nbs/g;
$arguments =~ s/^ +//;
$arguments =~ s/\\&"/\\(dq/g;
$arguments =~ s/^ *//;
while ( length $arguments ) {
my $a;
if ( $arguments =~ s/^"((?:[^"]|"")*)"(?!") *// ) {
my $a = $1;
$a = $1;
$a =~ s/""/"/g if defined $a;
push @args, $a;
} elsif ( $arguments =~ s/^"((?:[^"]|"")*) *$// ) {

# Unterminated quote, but this seems to be handled by removing
# the trailing spaces and closing the quotes.
my $a = $1;
$a = $1;
$a =~ s/""/"/g if defined $a;
push @args, $a;
} elsif ( $arguments =~ s/^([^ ]+) *// ) {
push @args, $1;
$a = $1;
} else {
die wrap_ref_mod( $ref, "po4a::man", dgettext( "po4a", "Cannot parse command arguments: %s" ), $arguments );
}
$a =~ s/\\&"/\\(dq/g if (defined $a);
push @args, $a;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just reading the code, it seems to me that we could push undef to @args if $a is not defined. If that's impossible, then the test at the end of line 1694 is probably useless.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've assumed it could be undef since there are analogous checks on lines 1682 and 1688. But now I don't see how it actually could. I suppose we can drop all those checks all together, right?

}
if ( $debug{'splitargs'} ) {
print STDERR "ARGS=";
Expand Down
2 changes: 2 additions & 0 deletions t/fmt/man/quotes.man
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,5 @@ should be equivalent to:

.BI "-help"""a "-h"a "-?"a "/?"

.\" Some shinenigans with \&, see https://github.com/mquinson/po4a/issues/445
.BI "[\& ]\&" \&"text\&" "[\& \&"" ]\&" "[\& \&"" ]\&
2 changes: 2 additions & 0 deletions t/fmt/man/quotes.norm
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,5 @@ should be equivalent to:

\fB\-help"\fP\fIa\fP\fB\-h\fP\fIa\fP\fB\-?\fP\fIa\fP\fB/?\fP

.\" Some shinenigans with \&, see https://github.com/mquinson/po4a/issues/445
\fB[\& ]\&\fP\fI"text"\fP\fB[\& " ]\&\fP\fI[\& " ]\&\fP
8 changes: 7 additions & 1 deletion t/fmt/man/quotes.po
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2020-04-26 22:14+0200\n"
"POT-Creation-Date: 2024-11-12 14:36+0300\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
Expand Down Expand Up @@ -83,3 +83,9 @@ msgstr "THIS ALSO:"
#: quotes.man:31 quotes.man:35
msgid "B<-help\">I<a>B<-h>I<a>B<-?>I<a>B</?>"
msgstr "B<-HELP\">I<1>B<-h>I<1>B<-?>I<1>B</?>"

#. Some shinenigans with \&, see https://github.com/mquinson/po4a/issues/445
#. type: Plain text
#: quotes.man:37
msgid "B<[\\& ]\\&>I<\"text\">B<[\\& \" ]\\&>I<[\\& \" ]\\&>"
msgstr "B<[\\& ]\\&>I<\"TEXT\">B<[\\& \" ]\\&>I<[\\& \" ]\\&>"
8 changes: 7 additions & 1 deletion t/fmt/man/quotes.pot
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2020-04-26 22:14+0200\n"
"POT-Creation-Date: 2024-11-12 14:36+0300\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
Expand Down Expand Up @@ -83,3 +83,9 @@ msgstr ""
#: quotes.man:31 quotes.man:35
msgid "B<-help\">I<a>B<-h>I<a>B<-?>I<a>B</?>"
msgstr ""

#. Some shinenigans with \&, see https://github.com/mquinson/po4a/issues/445
#. type: Plain text
#: quotes.man:37
msgid "B<[\\& ]\\&>I<\"text\">B<[\\& \" ]\\&>I<[\\& \" ]\\&>"
msgstr ""
2 changes: 2 additions & 0 deletions t/fmt/man/quotes.trans
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,5 @@ SHOULD BE EQUIVALENT TO:

\fB\-HELP"\fP\fI1\fP\fB\-h\fP\fI1\fP\fB\-?\fP\fI1\fP\fB/?\fP

.\" Some shinenigans with \&, see https://github.com/mquinson/po4a/issues/445
\fB[\& ]\&\fP\fI"TEXT"\fP\fB[\& " ]\&\fP\fI[\& " ]\&\fP
Loading