Skip to content

Commit 55598ae

Browse files
committed
Prevent custom_header with non-ASCII characters (sympa-community#1840)
1 parent 4f62c3a commit 55598ae

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

src/lib/Sympa/Config/Schema.pm

+2-2
Original file line numberDiff line numberDiff line change
@@ -1201,7 +1201,7 @@ our %pinfo = (
12011201
gettext_id => "Custom header field",
12021202
gettext_comment =>
12031203
'This parameter is optional. The headers specified will be added to the headers of messages distributed via the list. As of release 1.2.2 of Sympa, it is possible to put several custom header lines in the configuration file at the same time.',
1204-
format => '\S+:\s+.*',
1204+
format_s => '$header_field_name:.+',
12051205
occurrence => '0-n',
12061206
length => 30
12071207
},
@@ -1353,7 +1353,7 @@ our %pinfo = (
13531353
'Header fields to be removed before message distribution',
13541354
gettext_comment =>
13551355
"The removal happens after Sympa's own header fields are added; therefore, it is a convenient way to remove Sympa's own header fields (like \"X-Loop:\" or \"X-no-archive:\") if you wish.",
1356-
format => '\S+',
1356+
format_s => '$header_field_name(:.+)?',
13571357
default => 'none',
13581358
sample => 'X-no-archive',
13591359
occurrence => '0-n',

src/lib/Sympa/Regexps.pm

+2
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ use constant email =>
4747
use constant family_name => qr'[a-z0-9][a-z0-9\-\.\+_]*';
4848
## Allow \s for template names
4949
use constant template_name => qr'[a-zA-Z0-9][a-zA-Z0-9\-\.\+_\s]*';
50+
# cf. RFC5322, 2.2.
51+
use constant header_field_name => qr'[!-9;-~]+';
5052
#FIXME: Not matching with IPv6 address.
5153
use constant host => qr'[\w\.\-]+';
5254
use constant hostport => qr{(?:

src/lib/Sympa/Spindle/TransformOutgoing.pm

+2-2
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ sub _twist {
102102

103103
# Add custom header fields
104104
foreach my $i (@{$list->{'admin'}{'custom_header'}}) {
105-
$message->add_header($1, $2) if $i =~ /^([\S\-\:]*)\s(.*)$/;
105+
$message->add_header(split /\s*:\s*/, $i, 2) if 0 < index $i, ':';
106106
}
107107

108108
## Add RFC 2919 header field
@@ -143,7 +143,7 @@ sub _twist {
143143
## Useful to remove some header fields that Sympa has set
144144
if ($list->{'admin'}{'remove_outgoing_headers'}) {
145145
foreach my $field (@{$list->{'admin'}{'remove_outgoing_headers'}}) {
146-
my ($f, $v) = split /\s*:\s*/, $field;
146+
my ($f, $v) = split /\s*:\s*/, $field, 2;
147147
if (defined $v) {
148148
my @values = $message->get_header($f);
149149
my $i;

0 commit comments

Comments
 (0)