Commit 959534ba1149bb29b1c731b34df9a339a54753e6 introduces a regression
for the mssql dialect.

The referenced discussion:
https://list.orgmode.org/orgmode/du2p193mb24225f623dbf8b3d254d3c0e88...@du2p193mb2422.eurp193.prod.outlook.com/


This commit double escapes the mssql (and possibly the sqsh dialect, but
I have no way of testing) parameters.  For example to log into mssql you
supply a host name as well: user@host. I'm unsure of internally what's
going on exactly, but with this commit the username sent is user\@host
which is interpreted as a Windows login and is incorrect.

This is also an issue with passwords that contain special characters.

Instead we can remove the escaped quotes around the string and rely on
shell-quote-argument to do the proper escaping. Any additional escaping
can be left up to the user.



diff --git a/lisp/ob-sql.el b/lisp/ob-sql.el
index 3f6fdf553..5f1363693 100644
--- a/lisp/ob-sql.el
+++ b/lisp/ob-sql.el
@@ -168,10 +168,10 @@ using its alias."
 SQL Server on Windows and Linux platform."
   (mapconcat #'identity
             (delq nil
-                  (list (when host (format "-S \"%s\"" (shell-quote-argument 
host)))
-                        (when user (format "-U \"%s\"" (shell-quote-argument 
user)))
-                        (when password (format "-P \"%s\"" 
(shell-quote-argument password)))
-                        (when database (format "-d \"%s\"" 
(shell-quote-argument database)))))
+                  (list (when host (format "-S %s" (shell-quote-argument 
host)))
+                        (when user (format "-U %s" (shell-quote-argument 
user)))
+                        (when password (format "-P %s" (shell-quote-argument 
password)))
+                        (when database (format "-d %s" (shell-quote-argument 
database)))))
             " "))

 (defun org-babel-sql-dbstring-sqsh (host user password database)

Reply via email to