[interchange] Make JSON POST handling opt-in
David Christensen <[email protected]> Tue, 06 Jan 2015 18:11:22 +0000
| Newsgroups | gmane.comp.web.interchange.cvs |
|---|---|
| Message-ID | <[email protected]> |
commit c215c52115e9332a9b0a814824ae240eae3dc735 Author: David Christensen <[email protected]> Date: Tue Jan 6 12:11:12 2015 -0600 Make JSON POST handling opt-in lib/Vend/Config.pm | 3 ++- lib/Vend/Server.pm | 11 +++++------ 2 files changed, 7 insertions(+), 7 deletions(-) --- diff --git a/lib/Vend/Config.pm b/lib/Vend/Config.pm index 1f9a48a..fbc6e0b 100644 --- a/lib/Vend/Config.pm +++ b/lib/Vend/Config.pm @@ -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'], diff --git a/lib/Vend/Server.pm b/lib/Vend/Server.pm index 59a7a8e..e31c8f9 100644 --- a/lib/Vend/Server.pm +++ b/lib/Vend/Server.pm @@ -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; @@ -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;