Skip to content

fix(v2,v3): support double-quotes and commas in TNS connection string parameters - #741

Merged
sijms merged 2 commits into
sijms:masterfrom
mfielding:connstr-quote-fixes
Oct 7, 2026
Merged

sijms merged 2 commits into
sijms:masterfrom
mfielding:connstr-quote-fixes

Conversation

@mfielding

@mfielding mfielding commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #763

Problem

TNS connection strings can contain double-quoted strings like ssl_server_cert_dn="CN=adwc, O=Oracle" or SERVICE_NAME="my_service". When passed by go-ora to the database server, they can result in errors like ORA-12564. This occurs because go-ora either:

  • Fails to parse the connection string locally (for client-side parameters it recognizes, like SERVICE_NAME, because its internal regex does not expect quotes).
  • Transmits the raw connection descriptor over the wire exactly as provided, including the double quotes. The Oracle Database listener's protocol parser fails when encountering these nested double quotes inside the TNS wire packet

Fix

This PR aligns go-ora's connection descriptor parsing and serialization behavior with the official Oracle client, in both v2 and v3 (the affected code in configurations/database_info.go and connection_string.go is identical in both modules):

  • Generalized Quote Stripping: We now strip outer double quotes from any parameter values in the connection descriptor (using the regex (?i)([a-z0-9_]+\s*=\s*)"([^"]*)" before performing any local parsing or wire serialization. This fixes both local client-side parsing (e.g. for quoted SERVICE_NAME) and wire-level protocol compatibility (e.g. for ssl_server_cert_dn).
  • DSN Preservation: Fixed BuildUrl/BuildJDBC to prevent comma-splitting parts of the connStr query parameter, ensuring the connection descriptor is passed to the parser intact.

It also adds unit tests (in both v2 and v3) and refactors the unit test framework to improve readability and to identify testcases.

  • Added unit tests to verify that BuildJDBC does not split connection strings containing commas.
  • Added unit tests to TestUpdateDatabaseInfo to verify that both ssl_server_cert_dn and SERVICE_NAME wrapped in double quotes are correctly stripped and parsed.
  • Added unit tests to verify that escaped parentheses (e.g. \)), which are required when quotes are stripped from values containing parentheses, are correctly parsed and preserved.

Testing

In addition to the unit tests above:

  • Wire-Format Alignment: We verified against a local TCP loopback listener that the TNS Connect Packet generated by go-ora with this patch matches the wire format of the official Oracle Instant Client (Thick mode). Both clients strip the outer double quotes and preserve escaped parentheses (e.g., \) remains \) on the wire).
  • E2E Connection: Confirmed that connections to sample Oracle Autonomous Database 19c and 26ai instances succeed, even with embedded commas in a ssl_server_cert_dn

Note that this patch doesn't actually add support for client-side validation like ssl_server_cert_dn, but rather improves connection string parsing to allow these connections to succeed.

@mfielding
mfielding force-pushed the connstr-quote-fixes branch from c09c3b4 to 53aa4d6 Compare August 17, 2026 23:08
…rameters

Port of the v2 fix to v3: strip outer double quotes from descriptor values in UpdateDatabaseInfo before parsing and serialization, and stop BuildUrl from splitting the connStr option on commas. Adds the same unit tests as v2.
@mfielding
mfielding force-pushed the connstr-quote-fixes branch from 53aa4d6 to 120e3cb Compare October 1, 2026 20:41
@mfielding mfielding changed the title fix(v2): support double-quotes and commas in TNS connection string parameters fix(v2,v3): support double-quotes and commas in TNS connection string parameters Oct 1, 2026
@sijms
sijms merged commit 62f8a42 into sijms:master Oct 7, 2026
0 of 3 checks passed
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.

ORA-12564 error when TNS descriptor contains double-quoted values (e.g. SSL_SERVER_CERT_DN, SERVICE_NAME)

2 participants