From c614ff4a15c2f23545e08f2df71802641bc9598d Mon Sep 17 00:00:00 2001 From: Javier Sanz Olivera Date: Tue, 30 Jan 2018 00:37:30 +0100 Subject: [PATCH] Url password can have quoted special characters. --- redash/__init__.py | 6 ++++-- redash/settings/helpers.py | 4 +++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/redash/__init__.py b/redash/__init__.py index 9536436b..b5e6320e 100644 --- a/redash/__init__.py +++ b/redash/__init__.py @@ -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 diff --git a/redash/settings/helpers.py b/redash/settings/helpers.py index d5ecb420..7c558c59 100644 --- a/redash/settings/helpers.py +++ b/redash/settings/helpers.py @@ -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