Skip to content

fix(snippetz): escape quotes and backslashes in php/curl request bodies - #10495

Merged
hanspagel merged 1 commit into
scalar:mainfrom
charan-rathore:fix/snippetz-php-curl-escape-body
Oct 6, 2026
Merged

hanspagel merged 1 commit into
scalar:mainfrom
charan-rathore:fix/snippetz-php-curl-escape-body

Conversation

@charan-rathore

Copy link
Copy Markdown
Contributor

Problem

The PHP cURL code example puts request bodies inside a single quoted PHP string without escaping them. If a plain text body, an octet-stream body, or a JSON body that can't be parsed contains an apostrophe or a backslash, the generated code is not valid PHP. For example, the text it's fine becomes 'it's fine', which is a syntax error when a user copies it.

Other PHP targets (guzzle, laravel) already escape these values.

Solution

Use the existing objectToString helper from libs/php for these three body paths. It escapes backslashes and single quotes, the same way the guzzle and laravel examples do. Output for normal bodies does not change.

I added tests for a plain text body, an unparsable JSON body and an octet-stream body. All three fail without the fix.

Checklist

  • I explained why the change is needed.
  • I added a changeset.
  • I added tests.
  • I updated the documentation. (not needed, no docs describe this)

@changeset-bot

changeset-bot Bot commented Oct 5, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 7c4f871

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 25 packages
Name Type
@scalar/snippetz Patch
@scalar/java-integration Patch
@scalar/api-client Patch
@scalar/api-reference Patch
@scalar/blocks Patch
@scalar/workspace-store Patch
@scalar/nuxt Patch
@scalar/agent-chat Patch
@scalar/api-client-react Patch
scalar-app Patch
@scalarapi/docker-api-reference Patch
@scalar/aspire Patch
@scalar/aspnetcore Patch
@scalar/aws-lambda Patch
@scalar/azure-functions Patch
@scalar/fastify-api-reference Patch
scalar_api_reference Patch
@scalar/api-reference-react Patch
@scalar/server-side-rendering Patch
@scalar/mock-server Patch
@scalar/oas-utils Patch
@scalar/openapi-to-markdown Patch
@scalar/pre-post-request-scripts Patch
@scalar/sidebar Patch
@scalar/mock-server-docker Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@hanspagel
hanspagel force-pushed the fix/snippetz-php-curl-escape-body branch from aa37068 to 7c4f871 Compare October 6, 2026 09:31
@hanspagel
hanspagel temporarily deployed to production-netlify October 6, 2026 09:33 — with GitHub Actions Inactive
@hanspagel
hanspagel temporarily deployed to production-netlify October 6, 2026 09:33 — with GitHub Actions Inactive
@hanspagel
hanspagel temporarily deployed to production-netlify October 6, 2026 09:33 — with GitHub Actions Inactive
@hanspagel
hanspagel temporarily deployed to production-netlify October 6, 2026 09:33 — with GitHub Actions Inactive
@hanspagel
hanspagel temporarily deployed to production-netlify October 6, 2026 09:33 — with GitHub Actions Inactive
@hanspagel
hanspagel merged commit 300eb5c into scalar:main Oct 6, 2026
32 checks passed
@charan-rathore
charan-rathore deleted the fix/snippetz-php-curl-escape-body branch October 6, 2026 09:46
@scalar-release-bot scalar-release-bot Bot mentioned this pull request Oct 6, 2026

This branch was previously deployed

1 inactive deployment
production-netlify — 7c4f8710 Deployed Oct 6, 2026 by hanspagel via test-cdn-snapshots #3203
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