Skip to content

Do not add an extra % when escaping in SQLCommenter#631

Open
Westacular wants to merge 2 commits into
open-telemetry:mainfrom
Westacular:sqlcommenter_remove_extra_percent_escape
Open

Do not add an extra % when escaping in SQLCommenter#631
Westacular wants to merge 2 commits into
open-telemetry:mainfrom
Westacular:sqlcommenter_remove_extra_percent_escape

Conversation

@Westacular

Copy link
Copy Markdown

The formatter for SQLCommenter comments was calling urlencode to perform percent-escaping, and then adding an extra % to each escaped value with that idea that you need a second % to escape the percent symbols themselves for SQL.

But this isn't necessary, because it's inside a SQL comment (not a literal in a SQL query), and % has no special meaning there.

This was noted in the old Google SQLCommenter repo: google/sqlcommenter#168

... which specifically called out the PHP implementation as out-of-spec.

And the spec also makes it clear that the extra % character is not required: https://google.github.io/sqlcommenter/spec/#key-value-format

I've removed the Util method that was doing the extra % escaping, and switched formatComments to just call urlencode directly.

The formatter for SQLCommenter comments was calling `urlencode` to perform percent-escaping, and then adding an _extra_ % to each escaped value with that idea that you need a second % to escape the percent symbols themselves for SQL.

But this isn't necessary, because it's inside a SQL comment (not a literal in a SQL query), and % has no special meaning there.

This was noted in the old Google SQLCommenter repo: google/sqlcommenter#168

... which specifically called out the PHP implementation as out-of-spec.

And the spec also makes it clear that the extra % character is not required: https://google.github.io/sqlcommenter/spec/#key-value-format

I've removed the Util method that was doing the extra % escaping, and switched `formatComments` to just call `urlencode` directly.
@Westacular Westacular requested a review from a team as a code owner June 23, 2026 20:03
@welcome

welcome Bot commented Jun 23, 2026

Copy link
Copy Markdown

Thanks for opening your first pull request! If you haven't yet signed our Contributor License Agreement (CLA), then please do so that we can accept your contribution. A link should appear shortly in this PR if you have not already signed one.

@codecov

codecov Bot commented Jun 24, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.45%. Comparing base (edc589d) to head (95e8f7f).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##               main     #631      +/-   ##
============================================
- Coverage     80.46%   80.45%   -0.01%     
+ Complexity     1669     1668       -1     
============================================
  Files           116      116              
  Lines          6265     6262       -3     
============================================
- Hits           5041     5038       -3     
  Misses         1224     1224              
Flag Coverage Δ
Context/Swoole 0.00% <ø> (ø)
Exporter/Instana 49.80% <ø> (ø)
Instrumentation/AwsSdk 82.14% <ø> (ø)
Instrumentation/CakePHP 20.42% <ø> (ø)
Instrumentation/CodeIgniter 79.31% <ø> (ø)
Instrumentation/Curl 86.88% <ø> (ø)
Instrumentation/Doctrine 92.82% <ø> (ø)
Instrumentation/ExtAmqp 88.80% <ø> (ø)
Instrumentation/Guzzle 76.25% <ø> (ø)
Instrumentation/HttpAsyncClient 78.94% <ø> (ø)
Instrumentation/HttpConfig 28.76% <ø> (ø)
Instrumentation/IO 0.00% <ø> (ø)
Instrumentation/Laravel 76.37% <ø> (ø)
Instrumentation/MongoDB 76.84% <ø> (ø)
Instrumentation/MySqli 93.39% <ø> (ø)
Instrumentation/OpenAIPHP 86.71% <ø> (ø)
Instrumentation/PostgreSql 91.36% <ø> (ø)
Instrumentation/Psr14 77.41% <ø> (ø)
Instrumentation/Psr15 89.74% <ø> (ø)
Instrumentation/Psr16 97.43% <ø> (ø)
Instrumentation/Psr18 79.41% <ø> (ø)
Instrumentation/Psr6 97.56% <ø> (ø)
Instrumentation/Session 94.28% <ø> (ø)
Instrumentation/Slim 84.21% <ø> (ø)
Propagation/CloudTrace 90.69% <ø> (ø)
Propagation/Instana 98.07% <ø> (ø)
Propagation/ServerTiming 94.73% <ø> (ø)
Propagation/TraceResponse 94.73% <ø> (ø)
ResourceDetectors/Azure 91.66% <ø> (ø)
ResourceDetectors/DigitalOcean 100.00% <ø> (ø)
Sampler/Xray 78.38% <ø> (ø)
Shims/OpenTracing 92.99% <ø> (ø)
SqlCommenter 95.38% <100.00%> (-0.21%) ⬇️
Utils/Test 87.79% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/SqlCommenter/src/Utils.php 100.00% <100.00%> (ø)

Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update edc589d...95e8f7f. Read the comment docs.

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

@ChrisLightfootWild

Copy link
Copy Markdown
Contributor

@Westacular there's some tests that are failing after this change. Can you look to update those too please? 👍

@Westacular

Copy link
Copy Markdown
Author

@ChrisLightfootWild Oh, yes, oops. Done.

@ChrisLightfootWild

Copy link
Copy Markdown
Contributor

@jerrytfleung would you mind taking a look at these changes please?

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.

2 participants