1. Berry Phillips
  2. thumpy

Commits

Berry Phillips  committed 02a381e

Cloudfront now parses qs args. Default to those but check old-style hack urls if enabled.

  • Participants
  • Parent commits b143725
  • Branches default

Comments (0)

Files changed (1)

File thumpy.py

View file
  • Ignore whitespace
 
     def scale(self, w, h):
         if w > self.im.size[0]:
-            w = self.im.size[0]    
+            w = self.im.size[0]
 
         if h > self.im.size[1]:
-            h = self.im.size[1]    
+            h = self.im.size[1]
 
         self.im = self.im.resize((w, h), PILImage.ANTIALIAS)
 
         h = h or self.im.size[1]
 
         if w > self.im.size[0]:
-            w = self.im.size[0]    
+            w = self.im.size[0]
 
         if h > self.im.size[1]:
-            h = self.im.size[1]    
+            h = self.im.size[1]
 
         left = (self.im.size[0] / 2) - (w / 2)
         top = (self.im.size[1] / 2) - (h / 2)
     if path.startswith('/'):
         path = path[1:]
 
-    if config['cloudfront_ugliness']:
+    params = oparse_qs(environ['QUERY_STRING'])
+    filepath = path
+
+    if not params and config['cloudfront_ugliness']:
         # DIRTY CLOUDFRONT HACK HERE
-        # Stupid CloudFront doesn't pass query string arguments, so we have to
-        # put image change params into the path.
+        # Stupid CloudFront doesn't parse query string arguments,
+        # so we have to put image change params into the path.
+        
+        # UPDATE: Cloudfrond finally parses query string arguments.
+        # This is great, but we still need support old style URLs.
+
         pathparts = path.split('/')
+        tmp_params = oparse_qs(pathparts[0])
 
-        #path = environ['PATH_INFO'][1:]
-        filepath = '/'.join(pathparts[1:])
-
-        #params = oparse_qs(environ['QUERY_STRING'])
-        params = oparse_qs(pathparts[0])
-    else:
-        filepath = path
-        params = oparse_qs(environ['QUERY_STRING'])
+        if tmp_params:
+            params = tmp_params
+            filepath = '/'.join(pathparts[1:])
 
     if config['ignore_favicon'] and filepath == 'favicon.ico':
         return Http404(start_response)