perusio / drupal-with-nginx

Running Drupal using nginx: an idiosyncratically crafted bleeding edge configuration.
854 stars 246 forks source link

QUERY_STRING in fastcgi_drupal.conf causes incorrect splitting the uri on an encoded & #211

Closed tdm4 closed 6 years ago

tdm4 commented 9 years ago

There's a module that uses drupal_explode_tags() to show multiple tags. Unfortunately, if the tag has a '&' in it, it gets messed up:

correct behaviour: $_GET = Array ( [q] => taxonomy/autocomplete/field_content/News & Analysis, Da ) current behaviour: $_GET = Array ( [q] => taxonomy/autocomplete/field_content/News [Analysis,_Da] => )

Commenting out or deleting the first line in fastcgi_drupal.conf fixes the issue: fastcgi_param QUERY_STRING q=$uri&$args;

Is there a reason why QUERY_STRING is hard-coded in?

tdm4 commented 9 years ago

With this QUERY_STRING in place, you get double encoding problems so you'd get something like:

\U0026amp; which breaks the URL!

tdm4 commented 9 years ago

Never mind.. I think commenting out QUERY_STRING breaks stuff now. Will have to find another way around the double-encoding issue.

tdm4 commented 9 years ago

I found a solution that works:

In fastcgi_drupal.conf:

set_by_lua $escaped_uri 'return ngx.escape_uri(ngx.var.uri)'; fastcgi_param QUERY_STRING q=$escaped_uri&$args;

Does this seem reasonable to add/amend to the nginx config? Commenting out QUERY_STRING broke things.. so since there is no rewrite happening with @drupal, this appears to fix mangled URIs going to Drupal.

tdm4 commented 8 years ago

Any update on this? I've rolled this out to a great many Drupal sites. It helps if there is an ampersand in the taxonomy.

rodrigoaguilera commented 8 years ago

I'm using D8 and I ended up removing QUERY_STRING from fastcgi_params because it made the active-link js to stop working. I guess that drupal thinks is not working in clean url mode

tdm4 commented 6 years ago

Closing this as I think the project's unmaintained now. Our solution for Drupal 8 is to completely remove fastcgi_param QUERY_STRING from the file.