Skip to content

Commit

Permalink
Item13477: Compatibility with UTF-8 core on Foswiki 1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
gac410 committed Jun 26, 2015
1 parent abc4561 commit 52ea281
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions lib/Foswiki/Plugins/TopicInteractionPlugin/Attachments.pm
Expand Up @@ -277,6 +277,7 @@ sub urlEncode {
my ($infoOrText, $property) = @_;

my $text = defined($property)?$infoOrText->{$property}:$infoOrText;
$text = Foswiki::encode_utf8($text) if ( $Foswiki::UNICODE );
$text =~ s/([^0-9a-zA-Z-_.:~!*\/])/'%'.sprintf('%02X',ord($1))/ge;

return $text;
Expand Down
9 changes: 6 additions & 3 deletions lib/Foswiki/Plugins/TopicInteractionPlugin/Core.pm
Expand Up @@ -197,6 +197,7 @@ sub prepareAction {

# read parameters
my $topic = $params->{topic} || $session->{webTopic};
$topic = Foswiki::decode_utf8($topic) if ( $Foswiki::UNICODE );
my $web = $session->{webName};

($web, $topic) = Foswiki::Func::normalizeWebTopicName($web, $topic);
Expand Down Expand Up @@ -273,8 +274,10 @@ sub urlDecode {

$value =~ s/%([\da-f]{2})/chr(hex($1))/gei;
my $session = $Foswiki::Plugins::SESSION;
my $downgradedValue = $session->UTF82SiteCharSet($value);
$value = $downgradedValue if defined $downgradedValue;
unless ($Foswiki::UNICODE) {
my $downgradedValue = $session->UTF82SiteCharSet($value);
$value = $downgradedValue if defined $downgradedValue;
}

$value =~ s/^\s+//g;
$value =~ s/\s+$//g;
Expand Down Expand Up @@ -319,7 +322,7 @@ sub printJSONRPC {
}

$message = JSON::to_json($message, {pretty=>1});
$response->print($message);
$response->body($message);
}

##############################################################################
Expand Down

0 comments on commit 52ea281

Please sign in to comment.