summaryrefslogtreecommitdiff
path: root/biblio/bibtex/utils/bibcop/bibcop.pl
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2023-07-01 03:01:25 +0000
committerNorbert Preining <norbert@preining.info>2023-07-01 03:01:25 +0000
commit3a29216caca37803e25b84a50fd5f7f91ebc04d3 (patch)
tree45c329c33b2bc8601810e0983b3590448a3279ec /biblio/bibtex/utils/bibcop/bibcop.pl
parent711112a97f2a98854236304a216213632d61eeb7 (diff)
CTAN sync 202307010301
Diffstat (limited to 'biblio/bibtex/utils/bibcop/bibcop.pl')
-rwxr-xr-xbiblio/bibtex/utils/bibcop/bibcop.pl15
1 files changed, 11 insertions, 4 deletions
diff --git a/biblio/bibtex/utils/bibcop/bibcop.pl b/biblio/bibtex/utils/bibcop/bibcop.pl
index 8deffac263..276d435dab 100755
--- a/biblio/bibtex/utils/bibcop/bibcop.pl
+++ b/biblio/bibtex/utils/bibcop/bibcop.pl
@@ -752,11 +752,18 @@ sub listed_tags {
return '(' . join(', ', @sorted) . ')';
}
+# Make sure the text can safely be rendered in TeX.
+sub escape_tex {
+ my ($tex) = @_;
+ $tex =~ s/[^a-zA-Z0-9-.,+)(:;@ '"]/?/g;
+ return $tex;
+}
+
# Print ERROR message to the console and die.
sub error {
my ($txt) = @_;
if (exists $args{'--latex'}) {
- print "\\PackageError{bibcop}{$txt}{}\n";
+ print "\\PackageError{bibcop}{" . escape_tex($txt). "}{}\n";
} else {
print STDERR $txt . "\n";
}
@@ -768,7 +775,7 @@ sub debug {
my ($txt) = @_;
if (exists $args{'--verbose'}) {
if (exists $args{'--latex'}) {
- print "\\message{bibcop: $txt^^J}\n";
+ print "\\message{bibcop: " . escape_tex($txt) . "^^J}\n";
} else {
print $txt . "\n";
}
@@ -788,7 +795,7 @@ sub info {
sub warning {
my ($txt) = @_;
if (exists $args{'--latex'}) {
- print "\\PackageWarningNoLine{bibcop}{$txt}\n";
+ print "\\PackageWarningNoLine{bibcop}{" . escape_tex($txt) . "}\n";
} else {
print $txt . "\n";
}
@@ -822,7 +829,7 @@ if (@ARGV+0 eq 0 or exists $args{'--help'} or exists $args{'-?'}) {
" --latex Report errors in LaTeX format using \\PackageWarningNoLine command\n\n" .
"If any issues, report to GitHub: https://github.com/yegor256/bibcop");
} elsif (exists $args{'--version'} or exists $args{'-v'}) {
- info('0.0.13');
+ info('0.0.14');
} else {
my ($file) = grep { not($_ =~ /^--.*$/) } @ARGV;
if (not $file) {