I just spun up a new vps with ubuntu 16.04, nginx 1.10.3 and php 7.0 and copied my working site to it. The old site was on php5.6 and worked flawlessly.
The issue is that something is converting my encoded plus signs into spaces. I can prove it is the real request is encoding the + as %2B by using document inspector but straight up curl test also fails:
Test 1:
curl "my_https_url" --data "details=asdf+%2B+asdf" --compressed
array(1) { ["details"]=> string(11) "asdf asdf" } <-- 3 spaces
Test 2:
curl "my_https_url" --data-urlencoded "details=asdf+%2B+asdf" --compressed
array(1) { ["details"]=> string(11) "asdf + asdf" } <-- perfect
Test 3:
$.post("my_https_url",{details:"asdf + asdf"})
Document Inspector Encoded Form Data: details=asdf+%2B+asdf
array(1) { ["details"]=> string(11) "asdf asdf" } <-- 3 spaces
Test 4:
$.post("my_https_url",{details:"asdf %2B asdf"})
Document Inspector Encoded Form Data: details=asdf+%252B+asdf
array(1) { ["details"]=> string(11) "asdf + asdf" } <-- perfect
Test 5:
$.post("my_https_url",{details:"asdf+%2B+asdf"})
Document Inspector Encoded Form Data: details=asdf%2B%252B%2Basdf
array(1) { ["details"]=> string(11) "asdf + asdf" } <-- perfect
Test 6:
$.post("my_https_url",{details:encodeURI("asdf + asdf")})
Document Inspector Encoded Form Data: details=asdf%2520%2B%2520asdf
array(1) { ["details"]=> string(11) "asdf asdf" } <-- 3 spaces
Test 7:
$.post("my_https_url",{details:encodeURIComponent("asdf + asdf")})
Document Inspector Encoded Form Data: details=details=asdf%2520%252B%2520asdf
array(1) { ["details"]=> string(11) "asdf + asdf" } <-- perfect
Test 8:
$.post("my_https_url",$('<form><input name="details" value="asdf + asdf"></form>').serialize())
Document Inspector Encoded Form Data: details=details=details=asdf+%2B+asdf
array(1) { ["details"]=> string(11) "asdf asdf" } <-- 3 spaces
Test 9:
$.post("my_https_url",encodeURIComponent($('<form><input name="details" value="asdf + asdf"></form>').serialize()))
Document Inspector Encoded Form Data: details%3Dasdf%2520%252B%2520asdf
array(0) {} <-- not working
<?php
var_dump($_POST);
// I am expecting "asdf + asdf"
Is there a php extension that is causing this or is it nginx? I included the configs of both.
phpinfo: https://ibb.co/jZCxeQ
nginx config:
server {
listen 80;
# access_log /var/log/nginx/website.access_log;
error_log /var/log/nginx/website.error_log;
set $oldhost $host;
root PHP_FILES_LOCATION;
location ~* \.(?:ico|css|js|gif|jpg|png|html|htm)$ {
try_files $uri $uri/ /index.php;
expires 3d;
add_header Pragma public;
add_header Cache-Control "public";
}
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
location / {
index index.php index.htm index.html;
try_files $uri $uri/ /index.php;
}
location ~ json.php$ {
try_files $uri $uri/ /index.php;
# location ~ \..*/.*\.php$ {return 404;}
# expires 3d; add_header Pragma public; add_header
# Cache-Control "public";
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
fastcgi_buffers 16 16k;
fastcgi_buffer_size 32k;
# fastcgi_index index.php;
client_max_body_size 80m;
fastcgi_intercept_errors on;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ .php$ {
#location ~ \..*/.*\.php$ {return 404;}
try_files $uri $uri/ /404.php?$args;
#expires 1d;
add_header Pragma public;
client_max_body_size 80m;
add_header Cache-Control "public";
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
fastcgi_buffers 16 16k;
fastcgi_buffer_size 32k;
fastcgi_intercept_errors on;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}