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

Prevent custom_header with non-ASCII characters (#1840) #1844

Open
wants to merge 1 commit into
base: main
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
4 changes: 2 additions & 2 deletions src/lib/Sympa/Config/Schema.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1201,7 +1201,7 @@ our %pinfo = (
gettext_id => "Custom header field",
gettext_comment =>
'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.',
format => '\S+:\s+.*',
format_s => '$header_field_name:.+',
occurrence => '0-n',
length => 30
},
Expand Down Expand Up @@ -1353,7 +1353,7 @@ our %pinfo = (
'Header fields to be removed before message distribution',
gettext_comment =>
"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.",
format => '\S+',
format_s => '$header_field_name(:.+)?',
ldidry marked this conversation as resolved.
Show resolved Hide resolved
default => 'none',
sample => 'X-no-archive',
occurrence => '0-n',
Expand Down
2 changes: 2 additions & 0 deletions src/lib/Sympa/Regexps.pm
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ use constant email =>
use constant family_name => qr'[a-z0-9][a-z0-9\-\.\+_]*';
## Allow \s for template names
use constant template_name => qr'[a-zA-Z0-9][a-zA-Z0-9\-\.\+_\s]*';
# cf. RFC5322, 2.2.
use constant header_field_name => qr'[!-9;-~]+';
ldidry marked this conversation as resolved.
Show resolved Hide resolved
#FIXME: Not matching with IPv6 address.
use constant host => qr'[\w\.\-]+';
use constant hostport => qr{(?:
Expand Down
4 changes: 2 additions & 2 deletions src/lib/Sympa/Spindle/TransformOutgoing.pm
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ sub _twist {

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

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