forked from denisenkom/go-mssqldb
-
Notifications
You must be signed in to change notification settings - Fork 85
Add support for double-quoted values in ADO connection strings #283
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
Merged
Merged
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
5c1ba4c
Initial plan
Copilot f1c1028
Implement support for double-quoted values in ADO connection strings
Copilot 4794128
Fix UTF-8 handling in ADO connection string parsing
Copilot 1fb0c2c
Update version to 1.9.3 and add documentation for double-quoted values
Copilot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -111,6 +111,25 @@ func TestValidConnectionString(t *testing.T) { | |
{"MultiSubnetFailover=false", func(p Config) bool { return !p.MultiSubnetFailover }}, | ||
{"timezone=Asia/Shanghai", func(p Config) bool { return p.Encoding.Timezone.String() == "Asia/Shanghai" }}, | ||
{"Pwd=placeholder", func(p Config) bool { return p.Password == "placeholder" }}, | ||
|
||
// ADO connection string tests with double-quoted values containing semicolons | ||
{"server=test;password=\"pass;word\"", func(p Config) bool { return p.Host == "test" && p.Password == "pass;word" }}, | ||
{"password=\"[2+R2B6O:fF/[;]cJsr\"", func(p Config) bool { return p.Password == "[2+R2B6O:fF/[;]cJsr" }}, | ||
{"server=host;user id=user;password=\"complex;pass=word\"", func(p Config) bool { | ||
return p.Host == "host" && p.User == "user" && p.Password == "complex;pass=word" | ||
}}, | ||
{"password=\"value with \"\"quotes\"\" inside\"", func(p Config) bool { return p.Password == "value with \"quotes\" inside" }}, | ||
{"server=test;password=\"simple\"", func(p Config) bool { return p.Host == "test" && p.Password == "simple" }}, | ||
// Test case specifically for the reported issue #282 | ||
{"Server=tcp:sql.database.windows.net,1433;Initial Catalog=MyDatabase;User [email protected];Password=\"[2+R2B6O:fF/[;]cJsr\"", func(p Config) bool { | ||
return p.Host == "sql.database.windows.net" && p.Database == "MyDatabase" && p.User == "[email protected]" && p.Password == "[2+R2B6O:fF/[;]cJsr" | ||
}}, | ||
// Additional edge cases for double-quoted values | ||
{"password=\"\"", func(p Config) bool { return p.Password == "" }}, // Empty quoted password | ||
{"password=\";\"", func(p Config) bool { return p.Password == ";" }}, // Just a semicolon | ||
{"password=\";;\"", func(p Config) bool { return p.Password == ";;" }}, // Multiple semicolons | ||
{"server=\"host;name\";password=\"pass;word\"", func(p Config) bool { return p.Host == "host;name" && p.Password == "pass;word" }}, // Multiple quoted values | ||
|
||
// those are supported currently, but maybe should not be | ||
{"someparam", func(p Config) bool { return true }}, | ||
{";;=;", func(p Config) bool { return true }}, | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't this code use WriteRune instead of WriteByte?
Go strings are UTF-8 encoded and may have multi-byte characters. Include a test with multi-byte UTF8 character values. @copilot #Closed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in commit 4794128. Changed the function to properly handle UTF-8 runes by using WriteRune instead of WriteByte and iterating over runes instead of bytes. Added comprehensive test cases with multibyte UTF-8 characters including Cyrillic, Chinese, emoji, and accented characters.