Skip to content

Commit fdf7b17

Browse files
authored
Merge pull request #1479 from dhensby/pulls/sqlv8-escape
🐛 quote sqlv8 values
2 parents d4a976c + 75b74f6 commit fdf7b17

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

CHANGELOG.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
v9.1.3 (2023-??-??)
2+
-------------------
3+
[fix] Escape values that are added to the msnodesqlv8 connection string that we construct ((#1479)[https://github.com/tediousjs/node-mssql/pull/1479])
4+
15
v9.1.2 (2023-08-01)
26
-------------------
37
[fix] Support more named instance formats ([#1520](https://github.com/tediousjs/node-mssql/pull/1520))

lib/msnodesqlv8/connection-pool.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,15 @@ class ConnectionPool extends BaseConnectionPool {
3838
return this.config.options.trustedConnection ? 'Yes' : 'No'
3939
case 'encrypt':
4040
return this.config.options.encrypt ? 'Yes' : 'No'
41-
default:
42-
return this.config[key] != null ? this.config[key] : ''
41+
default: {
42+
let val = this.config[key] || ''
43+
// quote strings that contain '{' or '}' but not ones that start and end with them (assume they are already quoted)
44+
if (val && typeof val === 'string' && !(val.startsWith('{') && val.endsWith('}')) && (val.indexOf('{') !== -1 || val.indexOf('}') !== -1)) {
45+
// quote values in `{}` and escape any existing `}` chars
46+
val = `{${val.replace(/}/g, '}}')}}`
47+
}
48+
return val
49+
}
4350
}
4451
})
4552

0 commit comments

Comments
 (0)