Skip to content

Commit

Permalink
Make JSON POST handling opt-in
Browse files Browse the repository at this point in the history
  • Loading branch information
David Christensen committed Jan 6, 2015
1 parent ac36e8c commit c215c52
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
3 changes: 2 additions & 1 deletion lib/Vend/Config.pm
Expand Up @@ -513,7 +513,8 @@ sub global_directives {
['Catalog', 'catalog', ''],
['SubCatalog', 'catalog', ''],
['AutoVariable', 'autovar', 'UrlJoiner'],
['UnpackJSON', 'yesno', 'Yes'],
['EnableJSONPost', 'yesno', 'No'],
['UnpackJSON', 'yesno', 'Yes'],
['XHTML', 'yesno', 'No'],
['UTF8', 'yesno', $ENV{MINIVEND_DISABLE_UTF8} ? 'No' : 'Yes'],
['External', 'yesno', 'No'],
Expand Down
11 changes: 5 additions & 6 deletions lib/Vend/Server.pm
Expand Up @@ -43,11 +43,10 @@ use strict;
require JSON;
};
if ($@) {
::logGlobal(
$@ =~ /^Can't locate JSON/ ?
'No POST support for application/json without installing JSON module' :
"Error loading JSON module: $@"
);

if ($@ !~ /^Can't locate JSON/) {
::logGlobal("Error loading JSON module: $@");
}
}
else {
$Has_JSON = 1;
Expand Down Expand Up @@ -339,7 +338,7 @@ sub parse_cgi {
if ($CGI::content_type =~ m{^(?:multipart/form-data|application/x-www-form-urlencoded|application/xml|application/json)\b}i) {
parse_post(\$CGI::query_string, 1)
if $Global::TolerateGet;
if ($CGI::content_type =~ m{^application/json\s*(?:;|$)}i) {
if ($Global::EnableJSONPost && $CGI::content_type =~ m{^application/json\s*(?:;|$)}i) {
if (!$Has_JSON) {
::logGlobal('No POST support for application/json without installing JSON module');
goto INVALIDPOST;
Expand Down

0 comments on commit c215c52

Please sign in to comment.