这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@icedream
Copy link
Contributor

@icedream icedream commented Apr 9, 2024

Fixes #309.

The code made an assumption that if single/double quotes are used it can safely add backticks instead. This turned out to be not true for descriptions that used both.

This change makes quick work of it by just escaping all backticks in this particular conditional branch.

@vercel
Copy link

vercel bot commented Apr 9, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
hey-api-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 9, 2024 9:50am

@icedream icedream marked this pull request as ready for review April 9, 2024 09:26
@mrlubos
Copy link
Member

mrlubos commented Apr 9, 2024

Thanks @icedream, didn't even give me a chance to debug! Can you add a patch changeset so we can release a new version? pnpm changeset then Space to select, Enter to move to next section

@icedream icedream force-pushed the pr/fix-backticks-and-single-quotes-bad-escape branch from f028e8a to 4f6bc00 Compare April 9, 2024 09:42
@icedream
Copy link
Contributor Author

icedream commented Apr 9, 2024

It was an issue quickly identified in the code so I thought I would send the fix right along with the issue ticket. 😄 You're welcome!

EDIT: Changeset added!

@icedream icedream force-pushed the pr/fix-backticks-and-single-quotes-bad-escape branch from 4f6bc00 to 2c76592 Compare April 9, 2024 09:45
@icedream
Copy link
Contributor Author

icedream commented Apr 9, 2024

Just noticed the *.snaps are wrong, will fix it next push.

@icedream icedream force-pushed the pr/fix-backticks-and-single-quotes-bad-escape branch from 2c76592 to a8e9e33 Compare April 9, 2024 09:49
@icedream
Copy link
Contributor Author

icedream commented Apr 9, 2024

Made sure that the tests are passing locally now at least.

!value.endsWith('`')
) {
value = `\`${value}\``;
value = `\`${value.replace(/`/g, '\\`')}\``;

Check failure

Code scanning / CodeQL

Incomplete string escaping or encoding

This does not escape backslash characters in the input.
@codecov
Copy link

codecov bot commented Apr 9, 2024

Codecov Report

Attention: Patch coverage is 0% with 1 lines in your changes are missing coverage. Please review.

Project coverage is 85.77%. Comparing base (399a0ca) to head (a8e9e33).

Files Patch % Lines
packages/openapi-ts/src/compiler/utils.ts 0.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main     #310   +/-   ##
=======================================
  Coverage   85.77%   85.77%           
=======================================
  Files          72       72           
  Lines        4619     4619           
  Branches      542      542           
=======================================
  Hits         3962     3962           
  Misses        655      655           
  Partials        2        2           
Flag Coverage Δ
unittests 85.77% <0.00%> (ø)

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@mrlubos mrlubos merged commit 2d2a97f into hey-api:main Apr 9, 2024
@github-actions github-actions bot mentioned this pull request Apr 9, 2024
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.

Strings containing both single quotes and backticks are not escaped properly

2 participants