From e860d789aae50c97e941f3b104ac9dcbda50e470 Mon Sep 17 00:00:00 2001 From: Kyle Mahan Date: Wed, 27 Jan 2016 08:09:03 -0800 Subject: [PATCH] parse micropub queries with pyquerystring library Better handling of PHP's fancy urlencoded arrays --- deploy.sh | 2 +- woodwind/views.py | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/deploy.sh b/deploy.sh index 5a0dc14..6afb0be 100755 --- a/deploy.sh +++ b/deploy.sh @@ -12,6 +12,6 @@ cd $REMOTE_PATH git pull origin master \ && source venv/bin/activate \ && pip install --upgrade -r requirements.txt \ -&& sudo restart silopub +&& sudo restart woodwind '" diff --git a/woodwind/views.py b/woodwind/views.py index 62c4de9..fc5aca5 100644 --- a/woodwind/views.py +++ b/woodwind/views.py @@ -12,6 +12,7 @@ import hashlib import hmac import mf2py import mf2util +import pyquerystring import requests import re import urllib @@ -319,7 +320,9 @@ def update_micropub_syndicate_to(): 'Unexpected response querying micropub endpoint %s: %s', resp, resp.text) return - syndicate_tos = urllib.parse.parse_qs(resp.text).get('syndicate-to[]', []) + syndicate_tos = pyquerystring.parse(resp.text).get('syndicate-to', []) + if syndicate_tos and not isinstance(syndicate_tos, list): + syndicate_tos = list(syndicate_tos) flask_login.current_user.set_setting('syndicate-to', syndicate_tos) db.session.commit() @@ -498,8 +501,9 @@ def domain_for_url(url): @views.app_template_filter() def favicon_for_url(url): - return '//www.google.com/s2/favicons?' + urllib.parse.urlencode( - {'domain': url}) + return '//www.google.com/s2/favicons?' + urllib.parse.urlencode({ + 'domain': url, + }) @views.app_template_filter()