Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 quote sqlv8 values #1479

Merged
merged 1 commit into from
Aug 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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