Skip to content

Conversation

Copilot
Copy link

@Copilot Copilot AI commented Aug 13, 2025

This PR implements proper parsing of ADO.NET connection strings with support for double-quoted values that can contain special characters like semicolons.

Problem

ADO connection strings with passwords containing semicolons were incorrectly parsed because the parser would split on all semicolons, truncating values at the first semicolon encountered:

// This connection string would fail to parse the complete password
connStr := `Server=tcp:sql.database.windows.net,1433;Initial Catalog=MyDatabase;User [email protected];Password=[2+R2B6O:fF/[;]cJsr;`

config, _ := msdsn.Parse(connStr)
fmt.Println(config.Password) // "[2+R2B6O:fF/[" - truncated at semicolon!

Solution

Added support for double-quoted values in ADO connection strings, following ADO.NET connection string conventions:

  • Values enclosed in double quotes can contain semicolons and other special characters
  • Internal double quotes are escaped by doubling them ("")
  • Maintains full backward compatibility with existing connection strings
  • Proper UTF-8 handling for multibyte characters
// Now this works correctly with quoted password
connStr := `Server=tcp:sql.database.windows.net,1433;Initial Catalog=MyDatabase;User [email protected];Password="[2+R2B6O:fF/[;]cJsr";`

config, _ := msdsn.Parse(connStr)
fmt.Println(config.Password) // "[2+R2B6O:fF/[;]cJsr" - complete password!

Implementation Details

  • Modified splitConnectionString function to use a new splitAdoConnectionStringParts helper
  • Added proper state machine parsing for double-quoted values
  • Support for escaped quotes using "" sequence
  • UTF-8 rune-based parsing to handle multibyte characters correctly
  • Comprehensive test coverage including edge cases and the exact scenario from the issue

Usage Examples

// Simple quoted value with semicolon
"Password=\"my;password\""

// Multiple quoted values
"Server=\"host;name\";Password=\"pass;word\""

// Quoted value containing double quotes
"Password=\"value with \"\"quotes\"\" inside\""

// Multibyte UTF-8 characters
"Password=\"пароль;密码;🔐\""

Version and Documentation Updates

  • Updated driver version to 1.9.3
  • Added changelog entry for the fix
  • Updated README.md with documentation on using double-quoted values in ADO connection strings

Fixes #282.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@Copilot Copilot AI changed the title [WIP] ADO connection strings that have Passwords with semicolon (;) do not work Add support for double-quoted values in ADO connection strings Aug 13, 2025
Copilot finished work on behalf of shueybubbles August 13, 2025 19:41
@Copilot Copilot AI requested a review from shueybubbles August 13, 2025 19:41
@codecov-commenter
Copy link

codecov-commenter commented Aug 13, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 75.29%. Comparing base (e1eb509) to head (1fb0c2c).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #283      +/-   ##
==========================================
+ Coverage   75.27%   75.29%   +0.01%     
==========================================
  Files          33       33              
  Lines        6500     6512      +12     
==========================================
+ Hits         4893     4903      +10     
- Misses       1324     1325       +1     
- Partials      283      284       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

if char == '"' {
if inQuotes && i+1 < len(dsn) && dsn[i+1] == '"' {
// Double quote escape sequence - add both quotes to current part
current.WriteByte(char)
Copy link
Collaborator

@shueybubbles shueybubbles Aug 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WriteByte

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

Copy link
Author

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.

@shueybubbles
Copy link
Collaborator

shueybubbles commented Aug 13, 2025

@copilot Add test cases with multibyte UTF8 characters in the values. I believe the new code should use WriteRune instead of WriteByte #Closed

Replace WriteByte with WriteRune in splitAdoConnectionStringParts to properly handle multibyte UTF-8 characters. Add comprehensive test cases with Cyrillic, Chinese, emoji, and accented characters in quoted connection string values.

Co-authored-by: shueybubbles <[email protected]>
Copy link
Author

Copilot AI commented Aug 13, 2025

@copilot Add test cases with multibyte UTF8 characters in the values. I believe the new code should use WriteRune instead of WriteByte

Added in commit 4794128. The code now uses WriteRune instead of WriteByte and includes test cases with multibyte UTF-8 characters: Cyrillic (пароль), Chinese (服务器, 密码), emoji (🔐, 🗝️), and accented characters (café, naïve, résumé). All tests are passing. #Resolved

@Copilot Copilot AI requested a review from shueybubbles August 13, 2025 23:07
Copilot finished work on behalf of shueybubbles August 13, 2025 23:07
@shueybubbles shueybubbles marked this pull request as ready for review August 14, 2025 14:18
Copy link
Collaborator

@shueybubbles shueybubbles left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Update version.go to set the version to 1.9.3
  2. Update changelog.md to mention this fix in 1.9.3
  3. Update the README.md to document how to use values with semicolons

@copilot

@shueybubbles
Copy link
Collaborator

@copilot

  1. Update version.go to set the version to 1.9.3
  2. Update changelog.md to mention this fix in 1.9.3
  3. Update the README.md to document how to use values with semicolons

Copy link
Author

Copilot AI commented Aug 22, 2025

@copilot

  1. Update version.go to set the version to 1.9.3
  2. Update changelog.md to mention this fix in 1.9.3
    ...

All three updates have been completed in commit 1fb0c2c:

  1. ✅ Updated version.go to set the version to 1.9.3
  2. ✅ Updated CHANGELOG.md to mention the ADO connection string fix in 1.9.3
  3. ✅ Updated README.md to document how to use values with semicolons in double quotes

The documentation now clearly shows how to use double-quoted values in ADO connection strings, including examples with semicolons and escaped quotes. All tests are passing.

Copilot finished work on behalf of shueybubbles August 22, 2025 17:12
@Copilot Copilot AI requested a review from shueybubbles August 22, 2025 17:12
Copy link
Collaborator

@shueybubbles shueybubbles left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@shueybubbles shueybubbles merged commit 8c35947 into main Aug 25, 2025
9 checks passed
@shueybubbles shueybubbles deleted the copilot/fix-282 branch August 25, 2025 20:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ADO connection strings that have Passwords with semicolon (;) do not work
3 participants