fix(oracle): sanitize brackets in connection-URL userinfo before parse - #2448
Conversation
oracle:// URLs with '[' or ']' in credentials (e.g. oracle://user:p[a]ss@host/svc) raised ValueError from urlparse's IPv6 netloc check, so such connections could never be opened. Mirror the MySQL connector's userinfo sanitiser so bracketed credentials parse while legitimate bracketed IPv6 hosts still work.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
WalkthroughAdds a helper ChangesOracle URL parsing fix
Estimated code review effort: 2 (Simple) | ~10 minutes Sequence Diagram(s)sequenceDiagram
participant Caller as _make_oracle_connection
participant Parser as _parse_oracle_connection_url
participant Urlparse as urllib.parse.urlparse
participant OracleDB as oracledb.connect
Caller->>Parser: connection_url
Parser->>Parser: sanitize [/] in userinfo segment
Parser->>Urlparse: parse sanitized URL
Urlparse-->>Parser: parsed result
Parser-->>Caller: username, password, hostname, path
Caller->>OracleDB: connect(user, password, host, service_name)
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
oracle://connection URLs containing[or]in the userinfo (username/password) crashed withValueErrorfromurlparse's IPv6 netloc check.Motivation
_make_oracle_connectioncalledurlparse(url)directly. Python'surlparsetreats[/]anywhere in the netloc as IPv6 host delimiters, so a URL likeoracle://user:p[a]ss@host:1521/svcraisesValueError: 'host' does not appear to be an IPv4 or IPv6 addressbefore any connection is attempted — the credential can never be used.The MySQL connector already solved this exact problem with
_parse_mysql_connection_url, which escapes brackets in the userinfo segment only. This change mirrors that helper for Oracle (_parse_oracle_connection_url), keeping valid IPv6 hosts (oracle://user:pass@[::1]:1521/svc) intact.Verification
Regression test proof (fails without the fix):
The
ipv6test passes both with and without the fix, confirming no regression for legitimate bracketed IPv6 hosts.Apache-2.0 path (
core/**). One commit, two files.Summary by CodeRabbit
[or]no longer break parsing.