Skip to content

Commit

Permalink
Item13378: JSON produces UTF, which must be graunched to the site cha…
Browse files Browse the repository at this point in the history
…rset before being used. THIS WILL AFFECT ANYTHING THAT USES JSON where that JSON is embedded in the output HTML, for example in HTML5 data- attributes
  • Loading branch information
Comment committed Apr 22, 2015
1 parent 9ea8d00 commit e3eaac3
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions SubscribePlugin/lib/Foswiki/Plugins/SubscribePlugin.pm
Expand Up @@ -118,16 +118,19 @@ sub _SUBSCRIBE {
$tmpl =~ s/\$url/$url/g;

# REST parameters
my $data = HTML::Entities::encode_entities(
JSON::to_json(
{
subscribe_topic => "$web.$topic",
subscribe_subscriber => $who,
subscribe_remove => $unsubscribe,
validation_key => '?%NONCE%'
}
)
my $json = JSON::to_json(
{
subscribe_topic => "$web.$topic",
subscribe_subscriber => $who,
subscribe_remove => $unsubscribe,
validation_key => '?%NONCE%'
}
);

# $json is UTF8 - must convert to the site encoding
$json = $Foswiki::Plugins::SESSION->UTF82SiteCharSet($json);

my $data = HTML::Entities::encode_entities($json);
$tmpl =~ s/\%JSON_DATA\%/$data/g;

# Add nonce, required for Foswiki < 1.2
Expand Down

0 comments on commit e3eaac3

Please sign in to comment.