Url password can have quoted special characters.

This commit is contained in:
Javier Sanz Olivera 2018-01-30 00:37:30 +01:00
parent 817f2ba9af
commit c614ff4a15
2 changed files with 7 additions and 3 deletions

View File

@ -2,6 +2,7 @@ import os
import sys
import logging
import urlparse
import urllib
import redis
from flask import Flask, safe_join
from flask_sslify import SSLify
@ -53,8 +54,9 @@ def create_redis_connection():
redis_db = redis_url.path[1]
else:
redis_db = 0
r = redis.StrictRedis(host=redis_url.hostname, port=redis_url.port, db=redis_db, password=redis_url.password)
# Redis passwords might be quoted with special characters
redisPassword = urllib.unquote(redis_url.password)
r = redis.StrictRedis(host=redis_url.hostname, port=redis_url.port, db=redis_db, password=redisPassword)
return r

View File

@ -1,6 +1,7 @@
import json
import os
import urlparse
import urllib
def parse_db_url(url):
@ -14,7 +15,8 @@ def parse_db_url(url):
connection['host'] = url_parts.hostname
connection['port'] = url_parts.port
connection['user'] = url_parts.username
connection['password'] = url_parts.password
# Passwords might be quoted with special characters
connection['password'] = urllib.unquote(url_parts.password)
return connection