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
b098e9e7
Commit
b098e9e7
authored
May 11, 2021
by
IKEDA Soji
Browse files
Use encode_filesystem_safe() instead of escape_chars() for tracking
parent
39e3006a
Changes
5
Hide whitespace changes
Inline
Side-by-side
src/cgi/wwsympa.fcgi.in
View file @
b098e9e7
...
...
@@ -10073,10 +10073,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 +10311,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/Spindle/ProcessTask.pm
View file @
b098e9e7
...
...
@@ -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 @
b098e9e7
...
...
@@ -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 @
b098e9e7
...
...
@@ -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 @
b098e9e7
...
...
@@ -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,48 @@ sub upgrade {
$log
->
syslog
('
notice
',
'
...Done.
');
}
if
(
lower_version
(
$previous_version
,
'
6.2.63b.1
'))
{
_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
);
}
}
);
}
return
1
;
}
...
...
@@ -2433,23 +2480,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
;
}
}
}
foreach
my
$dir
(
@dirs
)
{
$sub
->
(
$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
'
/
';
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