Fix DSN parsing error for special characters in passwords#20
Merged
Conversation
Co-authored-by: intel352 <77607+intel352@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Database module - DSN parsing error
Fix DSN parsing error for special characters in passwords
Jul 7, 2025
Codecov ReportAttention: Patch coverage is
📢 Thoughts on this report? Let us know! |
Contributor
|
@copilot Linter errors are showing up, please fix any linter errors and ensure tests are still passing. |
Co-authored-by: intel352 <77607+intel352@users.noreply.github.com>
Contributor
Author
Contributor
|
Co-authored-by: intel352 <77607+intel352@users.noreply.github.com>
Contributor
Author
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
The database module was failing to parse DSN strings containing special characters in passwords. For example, this DSN would cause a parsing error:
The error occurred because Go's
url.Parse()function treats special characters like!,?,(,)as URL syntax instead of literal password characters, resulting in:Solution
Enhanced the DSN parsing logic in the database module to handle special characters in passwords by:
preprocessDSNForParsing()function that intelligently identifies the password portion and URL-encodes special characters@symbol to separate credentials from host, handling cases where passwords contain@symbolsextractEndpointFromDSN()andreplaceDSNPassword()to use the same preprocessing approachChanges
extractEndpointFromDSN()to preprocess DSNs with special charactersreplaceDSNPassword()to handle special characters consistentlypreprocessDSNForParsing()helper function for URL-encoding password portionsTest Coverage
Added extensive test cases covering:
@symbols, query parameters, and complex special characters@symbols and URL-like structures in passwordsAll existing tests continue to pass, ensuring no regressions.
Fixes #19.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.