ss::Accessor::Lite (
new => 1,
rw => [qw/req res stash args tx debug/]
);
use JSON qw//;
my $_JSON = JSON->new()->ascii(1);
my %_ESCAPE = (
'+' => '\\u002b', # do not eval as UTF-7
'
body );
$self->res;
}
sub render_json {
my $self = shift;
my $obj = shift;
# defense from JSON hijacking
# Copy from Amon2::Plugin::Web::JSON
if ( !$self->req->header('X-Requ
elf->halt(403,"Your request is maybe JSON hijacking.\nIf you are not a attacker, please add 'X-Requested-With' header to each request.");
}
# for IE7 JSON venularity.
# see http://www.atm
fire())},0)}function m(a){for(var b in a){if(b==="data"&&f.isEmptyObject(a[b]))continue;if(b!=="toJSON")return!1}return!0}function l(a,c,d){if(d===b&&a.nodeType===1){var e="data-"+c.replace(k,"-$1").t
{try{d=d==="true"?!0:d==="false"?!1:d==="null"?null:f.isNumeric(d)?parseFloat(d):j.test(d)?f.parseJSON(d):d}catch(g){}f.data(a,c,d)}else d=b}return d}function h(a){var b=g[a]={},c,d;a=a.split(/\s+/);f
n!0},error:function(a){throw new Error(a)},parseJSON:function(b){if(typeof b!="string"||!b)return null;b=e.trim(b);if(a.JSON&&a.JSON.parse)return a.JSON.parse(b);if(n.test(b.replace(o,"@").replace(p,"
(
new => 1,
rw => [qw/req res stash args tx debug json_serializer/]
);
use Kossy::Exception;
our $VERSION = '0.63';
# for IE7 JSON venularity.
# see http://www.atmarkit.co.jp/fcoding/articl
es/webapp/05/webapp05a.html
# Copy from Amon2::Plugin::Web::JSON => Fixed to escape only string parts
my %_ESCAPE = (
'+' => '\\u002b', # do not eval as UTF-7
'<' => '\\u003c', # do not eval a
my $body = shift;
$body =~ s!([+<>])!$_ESCAPE{$1}!g;
return qq("$body");
}
sub escape_json {
my $self = shift;
my $body = shift;
# escape only string parts
$body =~ s/"((?:
er::MultiPart'
);
my $json_parser = HTTP::Entity::Parser->new();
$json_parser->register(
'application/x-www-form-urlencoded',
'HTTP::Entity::Parser::UrlEncoded'
);
$json_parser->register(
t'
);
$json_parser->register(
'application/json',
'HTTP::Entity::Parser::JSON'
);
my $json_only_parser = HTTP::Entity::Parser->new();
$json_only_parser->register(
'application/json',
'HTTP::Entity::Parser::JSON'
);
sub _build_request_body_parser {
my $self = shift;
if ( $self->env->{'kossy.request.parse_json_body'} ) {
return $json_parser;
}
$default_parse