Bug #693

Package browser doesn't handle special character in URLs

Added by Paul Onyschuk almost 8 years ago. Updated almost 8 years ago.

Target version:
Start date:
Due date:
% Done:


Estimated time:


Packages with special characters in name like gtk+ can be searched, but not displayed in package browser:

There're few packages with "+" in names, maybe also with other characters, but nothing else comes to my mind right now.


#1 Updated by Jeff Bilyk almost 8 years ago

  • Category set to Wiki
  • Assignee set to Carlo Landmeter

Clandmeter, assigning this to your queue since it's your module :)

#2 Updated by Carlo Landmeter almost 8 years ago

  • File drupal.lua__2.txt added

The issue is caused by a lua script which translates regular url's into clean url's. I have looked into the script, but i couldn't find anything wrong. This is mostly caused by me not knowing lua well enough. If anybody can look into this script and provide a solution.

The script seems to do the following for pkgname gtk+2.0-dev:

original pkgname: gtk%2B2.0-dev
send to lighttpd: gtk 2.0-dev

Somehow it filters the special HTML chars and replaces it with a space.

#3 Updated by Natanael Copa almost 8 years ago

The problem is that the url gets decoded twice due to url rewriter.

The drupal.lua script will get the url "apk/main/x86/gtk%2B2.0" decoded as "apk/main/x86/gtk+2.0". The it will rewrite that into "?q=apk/main/x86/gtk+2.0" which will be decoded by php as $q="apk/main/x86/gtk 2.0".

A workaround for this is to urlencode the trimmed_path variable when remaking the uri.quey:

@@ -313,7 +313,10 @@
   -- append "q=<path>" (while stripping away the path to the Drupal installation
   -- if it's in there).
   if lighty.env['uri.query'] == nil or lighty.env['uri.query']:match('^q=') == nil then
-    lighty.env['uri.query'] = (lighty.env['uri.query'] == nil and '' or lighty.env['uri.query'] .. '&') .. 'q=' .. path_trimmed
+    lighty.env['uri.query'] = (lighty.env['uri.query'] == nil and '' or lighty.env['uri.query'] .. '&') .. 'q=' .. path_trimmed:gsub("[+&]", function(c)
+            -- we need urlencode the path_trimmed
+            return string.format("%%%02X", string.byte(c))
+    end)
   lighty.env['uri.path'] = d_path .. 'index.php'
   lighty.env['physical.rel-path'] = lighty.env['uri.path']

This will again encode '+' and '&' chars. We could add more chars there if those are not enough.

#4 Updated by Natanael Copa almost 8 years ago

  • Status changed from New to Resolved
  • Assignee changed from Carlo Landmeter to Natanael Copa
  • % Done changed from 0 to 100

#5 Updated by Natanael Copa almost 8 years ago

  • Status changed from Resolved to Closed

#6 Updated by Carlo Landmeter 9 months ago

  • File deleted (drupal.lua__2.txt)

Also available in: Atom PDF