Skip to content

Commit

Permalink
Merge pull request getredash#2266 from javier-sanz/quotedPasswords
Browse files Browse the repository at this point in the history
Url password can have quoted special characters.
  • Loading branch information
arikfr committed Feb 8, 2018
2 parents 07d8bab + 44c2526 commit f703a60
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 4 additions & 2 deletions redash/__init__.py
Expand Up @@ -2,6 +2,7 @@
import sys
import logging
import urlparse
import urllib
import redis
from flask import Flask, safe_join
from flask_sslify import SSLify
Expand Down Expand Up @@ -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
redis_password = redis_url.password and urllib.unquote(redis_url.password)
r = redis.StrictRedis(host=redis_url.hostname, port=redis_url.port, db=redis_db, password=redis_password)

return r

Expand Down
4 changes: 3 additions & 1 deletion redash/settings/helpers.py
@@ -1,6 +1,7 @@
import json
import os
import urlparse
import urllib


def parse_db_url(url):
Expand All @@ -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'] = url_parts.password and urllib.unquote(url_parts.password)

return connection

Expand Down

0 comments on commit f703a60

Please sign in to comment.