Skip to content

Commit

Permalink
fix: quote sqlv8 values
Browse files Browse the repository at this point in the history
  • Loading branch information
dhensby committed Aug 7, 2023
1 parent aa3b2be commit 75b74f6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
v9.1.3 (2023-??-??)
-------------------
[fix] Escape values that are added to the msnodesqlv8 connection string that we construct ((#1479)[https://github.com/tediousjs/node-mssql/pull/1479])

v9.1.2 (2023-08-01)
-------------------
[fix] Support more named instance formats ([#1520](https://github.com/tediousjs/node-mssql/pull/1520))
Expand Down
11 changes: 9 additions & 2 deletions lib/msnodesqlv8/connection-pool.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,15 @@ class ConnectionPool extends BaseConnectionPool {
return this.config.options.trustedConnection ? 'Yes' : 'No'
case 'encrypt':
return this.config.options.encrypt ? 'Yes' : 'No'
default:
return this.config[key] != null ? this.config[key] : ''
default: {
let val = this.config[key] || ''
// quote strings that contain '{' or '}' but not ones that start and end with them (assume they are already quoted)
if (val && typeof val === 'string' && !(val.startsWith('{') && val.endsWith('}')) && (val.indexOf('{') !== -1 || val.indexOf('}') !== -1)) {
// quote values in `{}` and escape any existing `}` chars
val = `{${val.replace(/}/g, '}}')}}`
}
return val
}
}
})

Expand Down

0 comments on commit 75b74f6

Please sign in to comment.