Ver código fonte

allow escape characters in password

version-14
Anand Doshi 14 anos atrás
pai
commit
25609d0b25
2 arquivos alterados com 9 adições e 2 exclusões
  1. +4
    -1
      cgi-bin/webnotes/model/db_schema.py
  2. +5
    -1
      cgi-bin/webnotes/utils/__init__.py

+ 4
- 1
cgi-bin/webnotes/model/db_schema.py Ver arquivo

@@ -357,8 +357,11 @@ class DbManager:
mysql_path = getattr(webnotes.defs, 'mysql_path', None) mysql_path = getattr(webnotes.defs, 'mysql_path', None)
mysql = mysql_path and os.path.join(mysql_path, 'mysql') or 'mysql' mysql = mysql_path and os.path.join(mysql_path, 'mysql') or 'mysql'
from webnotes.utils import make_esc
esc = make_esc('$ ')
try: try:
ret = os.system("%s -u root -p%s %s < %s"%(mysql, root_password.replace(" ", "\ "), target.replace("$", "\$"), source))
ret = os.system("%s -u root -p%s %s < %s"%(mysql, esc(root_password), esc(target), source))
except Exception,e: except Exception,e:
raise e raise e




+ 5
- 1
cgi-bin/webnotes/utils/__init__.py Ver arquivo

@@ -636,6 +636,10 @@ def get_file_timestamp(fn):
else: else:
return None return None



def make_esc(esc_chars):
"""
Function generator for Escaping special characters
"""
return lambda s: ''.join(['\\' + c if c in esc_chars else c for c in s])



Carregando…
Cancelar
Salvar