Commit 83026d6c authored by IKEDA Soji's avatar IKEDA Soji
Browse files

Preserve newlines in multi-line text.

parent 49def712
......@@ -746,7 +746,6 @@ sub dump_users {
next unless ref $user->{$k} eq 'HASH' and %{$user->{$k}};
my $encoded = Sympa::Tools::Data::encode_custom_attribute(
$user->{$k});
$encoded =~ s/[\r\n]+/ /g;
printf $lock_fh "%s %s\n", $k, $encoded;
} else {
next unless defined $user->{$k} and length $user->{$k};
......
......@@ -494,10 +494,11 @@ sub encode_custom_attribute {
$XMLstr .=
"<custom_attribute id=\"$k\"><value>"
. Sympa::Tools::Text::encode_html($value)
. Sympa::Tools::Text::encode_html($value, '\000-\037')
. "</value></custom_attribute>";
}
$XMLstr .= "</custom_attributes>";
$XMLstr =~ s/\s*\n\s*/ /g;
return $XMLstr;
}
......
......@@ -8,6 +8,9 @@
# Copyright (c) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
# 2006, 2007, 2008, 2009, 2010, 2011 Comite Reseau des Universites
# Copyright (c) 2011, 2012, 2013, 2014, 2015, 2016, 2017 GIP RENATER
# Copyright 2018 The Sympa Community. See the AUTHORS.md file at the
# top-level directory of this distribution and at
# <https://github.com/sympa-community/sympa.git>.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
......@@ -157,9 +160,10 @@ sub encode_filesystem_safe {
}
sub encode_html {
my $str = shift;
my $str = shift;
my $additional_unsafe = shift || '';
HTML::Entities::encode_entities($str, '<>&"');
HTML::Entities::encode_entities($str, '<>&"' . $additional_unsafe);
}
sub encode_uri {
......@@ -572,10 +576,11 @@ two hexdigits.
Note that C<'/'> will also be encoded.
=item encode_html ( $str )
=item encode_html ( $str, [ $additional_unsafe ] )
I<Function>.
Encodes characters in a string $str to HTML entities.
By default
C<'E<lt>'>, C<'E<gt>'>, C<'E<amp>'> and C<'E<quot>'> are encoded.
Parameter:
......@@ -586,6 +591,12 @@ Parameter:
String to be encoded.
=item $additional_unsafe
Character or range of characters additionally encoded as entity references.
This optional parameter was introduced on Sympa 6.2.37b.3.
=back
Returns:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment