Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Projets publics
Sympa
Commits
3264df0c
Unverified
Commit
3264df0c
authored
May 21, 2021
by
IKEDA Soji
Committed by
GitHub
May 21, 2021
Browse files
Merge pull request #1167 from ikedas/obsolete-escape_chars by ikedas
Obsolete escape_chars() / unescape_chars()
parents
a5808af3
33994164
Changes
8
Hide whitespace changes
Inline
Side-by-side
src/cgi/wwsympa.fcgi.in
View file @
3264df0c
...
...
@@ -8948,7 +8948,6 @@ sub do_remove_arc {
wwslog('info', 'List %s, yyyy %s, mm %s, #message %s',
$in{'list'}, $in{'yyyy'}, $in{'month'});
# $in{'msgid'} = Sympa::Tools::Text::unescape_chars($in{'msgid'});
my @msgids = split /\0/, $in{'msgid'};
my @msg_subjects = split /\0/, $in{'msg_subject'};
...
...
@@ -9467,7 +9466,6 @@ sub do_arcsearch_id {
return undef;
}
#$in{'msgid'} = Sympa::Tools::Text::unescape_chars($in{'msgid'});
$param->{'msgid'} = $in{'msgid'};
$search->limit(1);
...
...
@@ -10073,10 +10071,11 @@ sub do_viewbounce {
my $html_relpath;
if ($in{'email'}) {
my $escaped_email = Sympa::Tools::Text::escape_chars($in{'email'});
my $escaped_email =
Sympa::Tools::Text::encode_filesystem_safe($in{'email'});
$html_relpath =
$in{'envid'}
? sprintf('%s_%08s', $escaped_email, $in{'envid'})
? sprintf('%s_
_
%08s', $escaped_email, $in{'envid'})
: $escaped_email;
} elsif ($in{'dir'} and $in{'file'}) {
$html_relpath = $in{'dir'};
...
...
@@ -10310,7 +10309,8 @@ sub do_resetbounce {
foreach my $email (@emails) {
my $escaped_email = Sympa::Tools::Text::escape_chars($email);
my $escaped_email =
Sympa::Tools::Text::encode_filesystem_safe($email);
unless ($list->is_list_member($email)) {
Sympa::WWW::Report::reject_report_web('user',
...
...
src/lib/Sympa/Archive.pm
View file @
3264df0c
...
...
@@ -405,14 +405,6 @@ sub html_remove {
'
-rmm
'
=>
$msgid
);
# Remomve urlized message.
my
$url_dir
=
$list
->
{'
dir
'}
.
'
/urlized/
'
.
Sympa::Tools::Text::
escape_chars
(
$msgid
);
my
$error
;
File::Path::
remove_tree
(
$url_dir
,
{
error
=>
\
$error
});
return
1
;
}
...
...
src/lib/Sympa/List.pm
View file @
3264df0c
...
...
@@ -1208,37 +1208,6 @@ sub get_recipients_per_mode {
next
;
}
#XXX Following will be done by ProcessOutgoing spindle.
# # Message should be re-encrypted, however, user certificate is
# # missing.
# if ($message->{'smime_crypted'}
# and not -r $Conf::Conf{'ssl_cert_dir'} . '/'
# . Sympa::Tools::Text::escape_chars($user->{'email'})
# and not -r $Conf::Conf{'ssl_cert_dir'} . '/'
# . Sympa::Tools::Text::escape_chars($user->{'email'} . '@enc')) {
# my $subject = $message->{'decoded_subject'};
# my $sender = $message->{'sender'};
# unless (
# Sympa::send_file(
# $self,
# 'x509-user-cert-missing',
# $user->{'email'},
# { 'mail' =>
# {'subject' => $subject, 'sender' => $sender},
# 'auto_submitted' => 'auto-generated'
# }
# )
# ) {
# $log->syslog(
# 'notice',
# 'Unable to send template "x509-user-cert-missing" to %s',
# $user->{'email'}
# );
# }
# next;
# }
# # Otherwise it may be shelved encryption.
if
(
$user
->
{'
reception
'}
eq
'
txt
')
{
if
(
$user
->
{'
bounce_address
'})
{
push
@tabrcpt_txt_verp
,
$user
->
{'
email
'};
...
...
src/lib/Sympa/Message.pm
View file @
3264df0c
...
...
@@ -1117,9 +1117,9 @@ sub smime_encrypt {
my
$certfile
;
my
$entity
;
my
$base
=
$
Conf::
Conf
{'
ssl_cert_dir
'}
.
'
/
'
.
Sympa::Tools::Text::
e
scape_chars
(
$email
);
my
$base
=
sprintf
'
%s/%s
',
$
Conf::
Conf
{'
ssl_cert_dir
'}
,
Sympa::Tools::Text::
e
ncode_filesystem_safe
(
$email
);
if
(
-
f
$base
.
'
@enc
')
{
$certfile
=
$base
.
'
@enc
';
}
else
{
...
...
@@ -1353,8 +1353,8 @@ sub check_smime_signature {
# or a pair of single-purpose. save them, as email@addr if combined,
# or as email@addr@sign / email@addr@enc for split certs.
foreach
my
$c
(
keys
%certs
)
{
my
$filename
=
"
$Conf
::Conf{ssl_cert_dir}
/
"
.
Sympa::Tools::Text::
e
scape_chars
(
lc
(
$sender
)
)
;
my
$filename
=
sprintf
'
%s/%s
',
$
Conf::
Conf
{
ssl_cert_dir
}
,
Sympa::Tools::Text::
e
ncode_filesystem_safe
(
lc
$sender
);
if
(
$c
ne
'
both
')
{
unlink
$filename
;
# just in case there's an old cert left...
$filename
.=
"
\@
$c
";
...
...
src/lib/Sympa/Spindle/ProcessTask.pm
View file @
3264df0c
...
...
@@ -911,8 +911,11 @@ sub do_purge_orphan_bounces {
$user_ref
;
$user_ref
=
$list
->
get_next_bouncing_list_member
()
)
{
my
$user_id
=
$user_ref
->
{'
email
'};
$bounced_users
{
Sympa::Tools::Text::
escape_chars
(
$user_id
)}
=
1
;
$bounced_users
{
Sympa::Tools::Text::
encode_filesystem_safe
(
$user_ref
->
{
email
}
)
}
=
1
;
}
my
$bounce_dir
=
$list
->
get_bounce_dir
();
...
...
@@ -935,10 +938,10 @@ sub do_purge_orphan_bounces {
while
(
$marshalled
=
readdir
$dh
)
{
my
$metadata
=
Sympa::Spool::
unmarshal_metadata
(
$bounce_dir
,
$marshalled
,
qr/\A([^\s\@]+\@[\w\.\-*]+?)(?:_(\w+))?\z/
,
qr/\A([^\s\@]+\@[\w\.\-*]+?)(?:_
_
(\w+))?\z/
,
[
qw(recipient envid)
]);
next
unless
$metadata
;
# Skip <email>_<envid> which is used by tracking feature.
# Skip <email>_
_
<envid> which is used by tracking feature.
next
if
defined
$metadata
->
{
envid
};
unless
(
$bounced_users
{
$marshalled
})
{
...
...
@@ -1014,7 +1017,8 @@ sub do_expire_bounce {
$email
);
next
;
}
my
$escaped_email
=
Sympa::Tools::Text::
escape_chars
(
$email
);
my
$escaped_email
=
Sympa::Tools::Text::
encode_filesystem_safe
(
$email
);
my
$bounce_dir
=
$list
->
get_bounce_dir
();
...
...
src/lib/Sympa/Tools/Text.pm
View file @
3264df0c
...
...
@@ -249,32 +249,8 @@ sub encode_uri {
}
# Old name: tools::escape_chars().
sub
escape_chars
{
my
$s
=
shift
;
my
$except
=
shift
;
## Exceptions
my
$ord_except
=
ord
$except
if
defined
$except
;
## Escape chars
## !"#$%&'()+,:;<=>?[] AND accented chars
## escape % first
foreach
my
$i
(
0x25
,
0x20
..
0x24
,
0x26
..
0x2c
,
0x3a
..
0x3f
,
0x5b
,
0x5d
,
0x80
..
0x9f
,
0xa0
..
0xff
)
{
next
if
defined
$ord_except
and
$i
==
$ord_except
;
my
$hex_i
=
sprintf
"
%lx
",
$i
;
$s
=~
s/\x$hex_i/%$hex_i/g
;
}
## Special traetment for '/'
$s
=~
s/\//%a5/g
unless
defined
$except
and
$except
eq
'
/
';
return
$s
;
}
# Moved to: Sympa::Upgrade::_escape_chars()
#sub escape_chars;
# Old name: tt2::escape_url().
# DEPRECATED. Use Sympa::Tools::Text::escape_uri() or
...
...
@@ -539,19 +515,8 @@ sub _gc_length {
}
# Old name: tools::unescape_chars().
sub
unescape_chars
{
my
$s
=
shift
;
$s
=~
s/%a5/\//g
;
## Special traetment for '/'
foreach
my
$i
(
0x20
..
0x2c
,
0x3a
..
0x3f
,
0x5b
,
0x5d
,
0x80
..
0x9f
,
0xa0
..
0xff
)
{
my
$hex_i
=
sprintf
"
%lx
",
$i
;
my
$hex_s
=
sprintf
"
%c
",
$i
;
$s
=~
s/%$hex_i/$hex_s/g
;
}
return
$s
;
}
# Moved to: Sympa::Upgrade::_unescape_chars().
#sub unescape_chars;
# Old name: tools::valid_email().
sub
valid_email
{
...
...
@@ -770,10 +735,10 @@ Encoded string, stripped C<utf8> flag if any.
=item escape_chars ( $str )
Escape weird characters.
B<Deprecated>.
Use L</encode_filesystem_safe>.
ToDo: This should be obsoleted in the future release: Would be better to use
L</encode_filesystem_safe>.
Escape weird characters.
=item escape_url ( $str )
...
...
@@ -906,10 +871,10 @@ C<$file> is the path to text file.
=item unescape_chars ( $str )
Unescape weird characters.
B<Deprecated>.
Use L</decode_filesystem_safe>.
ToDo: This should be obsoleted in the future release: Would be better to use
L</decode_filesystem_safe>.
Unescape weird characters.
=item valid_email ( $string )
...
...
src/lib/Sympa/Tracking.pm
View file @
3264df0c
...
...
@@ -264,8 +264,8 @@ sub store {
unless
(
_db_insert_notification
(
$rcpt
,
%options
))
{
return
undef
;
}
$filename
=
sprintf
'
%s_%08s
',
Sympa::Tools::Text::
e
scape_chars
(
$rcpt
),
$filename
=
sprintf
'
%s_
_
%08s
',
Sympa::Tools::Text::
e
ncode_filesystem_safe
(
$rcpt
),
$options
{
envid
};
}
else
{
unless
(
...
...
@@ -275,7 +275,7 @@ sub store {
$rcpt
,
$self
->
{
context
});
return
undef
;
}
$filename
=
Sympa::Tools::Text::
e
scape_chars
(
$rcpt
);
$filename
=
Sympa::Tools::Text::
e
ncode_filesystem_safe
(
$rcpt
);
}
unless
(
open
$ofh
,
'
>
',
$bounce_dir
.
'
/
'
.
$filename
)
{
$log
->
syslog
('
err
',
'
Unable to write %s/%s
',
$bounce_dir
,
$filename
);
...
...
@@ -479,7 +479,7 @@ sub remove_message_by_email {
return
undef
unless
$email
;
my
$bounce_dir
=
$self
->
{
directory
};
my
$escaped_email
=
Sympa::Tools::Text::
e
scape_chars
(
$email
);
my
$escaped_email
=
Sympa::Tools::Text::
e
ncode_filesystem_safe
(
$email
);
my
$ret
=
unlink
sprintf
('
%s/%s
',
$bounce_dir
,
$escaped_email
);
# Remove HTML view.
...
...
@@ -540,9 +540,9 @@ sub remove_message_by_id {
while
(
my
$info
=
$sth
->
fetchrow_hashref
('
NAME_lc
'))
{
my
$bounce_dir
=
$self
->
{
directory
};
my
$escaped_email
=
Sympa::Tools::Text::
e
scape_chars
(
$info
->
{'
recipient
'});
Sympa::Tools::Text::
e
ncode_filesystem_safe
(
$info
->
{'
recipient
'});
my
$envid
=
$info
->
{'
envid
'};
unlink
sprintf
('
%s/%s_%08s
',
$bounce_dir
,
$escaped_email
,
$envid
);
unlink
sprintf
('
%s/%s_
_
%08s
',
$bounce_dir
,
$escaped_email
,
$envid
);
}
$sth
->
finish
;
...
...
@@ -619,9 +619,9 @@ sub remove_message_by_period {
while
(
my
$info
=
$sth
->
fetchrow_hashref
('
NAME_lc
'))
{
my
$bounce_dir
=
$self
->
{
directory
};
my
$escaped_email
=
Sympa::Tools::Text::
e
scape_chars
(
$info
->
{'
recipient
'});
Sympa::Tools::Text::
e
ncode_filesystem_safe
(
$info
->
{'
recipient
'});
my
$envid
=
$info
->
{'
envid
'};
unlink
sprintf
('
%s/%s_%08s
',
$bounce_dir
,
$escaped_email
,
$envid
);
unlink
sprintf
('
%s/%s_
_
%08s
',
$bounce_dir
,
$escaped_email
,
$envid
);
}
$sth
->
finish
;
...
...
src/lib/Sympa/Upgrade.pm
View file @
3264df0c
...
...
@@ -1366,9 +1366,12 @@ sub upgrade {
and
length
$msg_string
and
$recipient
)
{
$msg_string
=
MIME::Base64::
decode_base64
(
$msg_string
);
# Note: See also upgrading from versions later than 6.2b.3
# to version 6.2.63b.1 in below.
# below.
my
$bounce_path
=
sprintf
'
%s/%s_%08s
',
$list
->
get_bounce_dir
,
Sympa::Tools::Text::
escape_chars
(
$recipient
),
_
escape_chars
(
$recipient
),
$info
->
{'
pk_notification
'};
if
(
open
my
$fh
,
'
>
',
$bounce_path
)
{
print
$fh
$msg_string
;
...
...
@@ -2078,6 +2081,7 @@ sub upgrade {
_process_all_files
(
'
mhonarc-ressources.tt2
',
sub
{
my
$that
=
shift
;
my
$dir
=
shift
;
my
$oldfile
=
shift
;
my
$newfile
=
'
mhonarc_rc.tt2
';
...
...
@@ -2103,6 +2107,7 @@ sub upgrade {
_process_all_files
(
'
search_filters/blacklist.txt
',
sub
{
my
$that
=
shift
;
my
$dir
=
shift
;
my
$oldfile
=
shift
;
my
$newfile
=
'
search_filters/blocklist.txt
';
...
...
@@ -2116,6 +2121,68 @@ sub upgrade {
$log
->
syslog
('
notice
',
'
...Done.
');
}
if
(
lower_version
(
$previous_version
,
'
6.2.63b.1
'))
{
$log
->
syslog
('
notice
',
'
Moving bounce information and so on...
');
_process_all_files
(
'
config
',
sub
{
my
$that
=
shift
;
my
$dir
=
shift
;
my
$file
=
shift
;
return
unless
ref
$that
eq
'
Sympa::List
';
# Note: See also upgrading to version 6.2b.3 in above.
my
$bounce_dir
=
$that
->
get_bounce_dir
;
my
$dh
;
return
unless
-
d
$bounce_dir
and
opendir
$dh
,
$bounce_dir
;
foreach
my
$old
(
readdir
$dh
)
{
next
if
0
==
index
$old
,
'
.
';
next
unless
$old
=~
/\A(.+)(?:_(\w+))?\z/
;
my
(
$escaped_email
,
$envid
)
=
(
$
1
,
$
2
);
my
$new
;
if
(
defined
$envid
)
{
$new
=
sprintf
'
%s/%s__%08s
',
Sympa::Tools::Text::
encode_filesystem_safe
(
_unescape_chars
(
$escaped_email
)),
$envid
;
}
else
{
$new
=
Sympa::Tools::Text::
encode_filesystem_safe
(
_unescape_chars
(
$escaped_email
));
}
next
if
$old
eq
$new
;
rename
sprintf
('
%s/%s
',
$bounce_dir
,
$old
),
sprintf
('
%s/%s
',
$bounce_dir
,
$new
);
}
}
);
my
$dh
;
if
(
opendir
$dh
,
$
Conf::
Conf
{'
ssl_cert_dir
'})
{
foreach
my
$old
(
readdir
$dh
)
{
next
if
0
==
index
$old
,
'
.
';
my
(
$escaped_email
,
$ext
)
=
(
$old
=~
/\A(.+)(?:(\@\w+)?)\z/
);
my
$new
=
Sympa::Tools::Text::
encode_filesystem_safe
(
_unescape_chars
(
$escaped_email
))
.
(
$ext
//
'');
next
if
$old
eq
$new
;
rename
sprintf
('
%s/%s
',
$
Conf::
Conf
{'
ssl_cert_dir
'},
$old
),
sprintf
('
%s/%s
',
$
Conf::
Conf
{'
ssl_cert_dir
'},
$new
);
}
}
$log
->
syslog
('
notice
',
'
...Done.
');
}
return
1
;
}
...
...
@@ -2433,23 +2500,62 @@ sub _process_all_files {
my
$file
=
shift
;
my
$sub
=
shift
;
my
@dirs
;
push
@dirs
,
$
Conf::
Conf
{'
etc
'}
$sub
->
('
*
',
$
Conf::
Conf
{'
etc
'},
$file
)
if
-
f
$
Conf::
Conf
{'
etc
'}
.
'
/
'
.
$file
;
foreach
my
$robot
(
Sympa::List::
get_robots
())
{
my
$dir
=
sprintf
'
%s/%s
',
$
Conf::
Conf
{'
etc
'},
$robot
;
push
@
dir
s
,
$
dir
$sub
->
(
$robot
,
$
dir
,
$
file
)
if
-
f
$dir
.
'
/
'
.
$file
;
foreach
my
$list
(
@
{
Sympa::List::
get_lists
(
$robot
)
||
[]
})
{
push
@dirs
,
$list
->
{'
dir
'}
$sub
->
(
$list
,
$list
->
{'
dir
'}
,
$file
)
if
-
f
$list
->
{'
dir
'}
.
'
/
'
.
$file
;
}
}
}
# Old name: tools::escape_chars(), Sympa::Tools::Text::escape_chars().
sub
_escape_chars
{
my
$s
=
shift
;
my
$except
=
shift
;
## Exceptions
my
$ord_except
=
ord
$except
if
defined
$except
;
## Escape chars
## !"#$%&'()+,:;<=>?[] AND accented chars
## escape % first
foreach
my
$i
(
0x25
,
0x20
..
0x24
,
0x26
..
0x2c
,
0x3a
..
0x3f
,
0x5b
,
0x5d
,
0x80
..
0x9f
,
0xa0
..
0xff
)
{
next
if
defined
$ord_except
and
$i
==
$ord_except
;
my
$hex_i
=
sprintf
"
%lx
",
$i
;
$s
=~
s/\x$hex_i/%$hex_i/g
;
}
## Special traetment for '/'
$s
=~
s/\//%a5/g
unless
defined
$except
and
$except
eq
'
/
';
foreach
my
$dir
(
@dirs
)
{
$sub
->
(
$dir
,
$file
);
return
$s
;
}
# Old name: tools::unescape_chars(), Sympa::Tools::Text::unescape_chars().
sub
_unescape_chars
{
my
$s
=
shift
;
$s
=~
s/%a5/\//g
;
## Special traetment for '/'
foreach
my
$i
(
0x20
..
0x2c
,
0x3a
..
0x3f
,
0x5b
,
0x5d
,
0x80
..
0x9f
,
0xa0
..
0xff
)
{
my
$hex_i
=
sprintf
"
%lx
",
$i
;
my
$hex_s
=
sprintf
"
%c
",
$i
;
$s
=~
s/%$hex_i/$hex_s/g
;
}
return
$s
;
}
1
;
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment