← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~wgrant/launchpad/no-tlt-encoded into lp:launchpad

 

William Grant has proposed merging lp:~wgrant/launchpad/no-tlt-encoded into lp:launchpad.

Commit message:
Drop compatibility for TimeLimitedTokens with encoded tildes. The new normal form has been in place for months.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~wgrant/launchpad/no-tlt-encoded/+merge/291853

Drop compatibility for TimeLimitedTokens with encoded tildes.

I meant to land this after we stopped generating them in like December, but forgot.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~wgrant/launchpad/no-tlt-encoded into lp:launchpad.
=== modified file 'lib/lp/services/librarianserver/db.py'
--- lib/lp/services/librarianserver/db.py	2015-12-10 00:37:05 +0000
+++ lib/lp/services/librarianserver/db.py	2016-04-14 06:44:40 +0000
@@ -13,7 +13,6 @@
 
 from storm.expr import (
     And,
-    Or,
     SQL,
     )
 
@@ -69,18 +68,12 @@
             # forcibly decodes it in any URL that it sees.
             #
             # This needs to match url_path_quote.
-            plain_tilde_path = urllib.quote(urllib.unquote(path), safe='/~+')
-            # XXX wgrant 2015-12-09: We used to generate URLs with
-            # escaped tildes, so support those until the tokens are all
-            # expired.
-            encoded_tilde_path = urllib.quote(urllib.unquote(path), safe='/')
+            normalised_path = urllib.quote(urllib.unquote(path), safe='/~+')
             store = session_store()
             token_found = store.find(TimeLimitedToken,
                 SQL("age(created) < interval '1 day'"),
                 TimeLimitedToken.token == hashlib.sha256(token).hexdigest(),
-                Or(
-                    TimeLimitedToken.path == plain_tilde_path,
-                    TimeLimitedToken.path == encoded_tilde_path)).is_empty()
+                TimeLimitedToken.path == normalised_path).is_empty()
             store.reset()
             if token_found:
                 raise LookupError("Token stale/pruned/path mismatch")


Follow ups