Skip to content

fix(think-helper): escapeHtml should turn a double quote into ", not &quote; - #1793

Merged
lizheming merged 2 commits into
thinkjs:masterfrom
lee3Q:fix/helper-escape-html-quot
Nov 4, 2026
Merged

lizheming merged 2 commits into
thinkjs:masterfrom
lee3Q:fix/helper-escape-html-quot

Conversation

@lee3Q

@lee3Q lee3Q commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

escapeHtml replaces " with &quote;, which is not an HTML entity. As text, a browser decodes it as "e;, and in an attribute value the literal string &quote; is kept, so a query value like a"b that think-pagination puts into a link comes out wrong.

This changes the replacement to ". The existing test escapeHtml 1 asserted the old string, so its expected value is updated.

Compatibility note: code, snapshots or stored data that match the old &quote; string will change. & is still not escaped by this helper; this PR does not change that.

node --test --test-concurrency=1 test/index.js in packages/think-helper (Node v22.23.4):

  • base with the updated test: 77 tests, 76 pass, 1 fail
  • with the fix: 77 pass, 0 fail
  • npx eslint index.js: exit 0

@codecov

codecov Bot commented Nov 4, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 72.75%. Comparing base (3d23253) to head (e61354e).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1793   +/-   ##
=======================================
  Coverage   72.75%   72.75%           
=======================================
  Files         241      241           
  Lines       19183    19183           
=======================================
  Hits        13956    13956           
  Misses       5227     5227           
Components Coverage Δ
think-apollo-graphql 0.00% <ø> (ø)
think-awesome ∅ <ø> (∅)
think-babel 100.00% <ø> (ø)
think-cache 100.00% <ø> (ø)
think-cache-file 100.00% <ø> (ø)
think-cache-memcache 0.00% <ø> (ø)
think-cache-redis 96.82% <ø> (ø)
think-cli 39.70% <ø> (ø)
think-cluster 78.90% <ø> (ø)
think-config 100.00% <ø> (ø)
think-controller 100.00% <ø> (ø)
think-crontab 100.00% <ø> (ø)
think-csrf 98.38% <ø> (ø)
think-debounce 100.00% <ø> (ø)
think-demo 0.00% <ø> (ø)
think-email 0.00% <ø> (ø)
think-fetch 100.00% <ø> (ø)
think-gc 100.00% <ø> (ø)
think-helmet 100.00% <ø> (ø)
think-helper 99.15% <100.00%> (ø)
think-i18n 49.19% <ø> (ø)
think-inspect 100.00% <ø> (ø)
think-instance 100.00% <ø> (ø)
think-knex 100.00% <ø> (ø)
think-loader 90.57% <ø> (ø)
think-logger 68.29% <ø> (ø)
think-logger3 68.07% <ø> (ø)
think-logic 100.00% <ø> (ø)
think-memcache 0.00% <ø> (ø)
think-meta 100.00% <ø> (ø)
think-mock 0.00% <ø> (ø)
think-mock-http 87.93% <ø> (ø)
think-model 88.58% <ø> (ø)
think-model-abstract 96.19% <ø> (ø)
think-model-mysql 95.70% <ø> (ø)
think-model-mysql2 95.70% <ø> (ø)
think-model-postgresql 97.97% <ø> (ø)
think-model-sqlite 88.96% <ø> (ø)
think-mongo 0.00% <ø> (ø)
think-mongoose 60.08% <ø> (ø)
think-mysql 89.66% <ø> (ø)
think-mysql2 89.66% <ø> (ø)
think-pagination 98.42% <ø> (ø)
think-payload 97.95% <ø> (ø)
think-pm2 100.00% <ø> (ø)
think-proxy 91.07% <ø> (ø)
think-qs 100.00% <ø> (ø)
think-ratelimiter 0.00% <ø> (ø)
think-redis 97.57% <ø> (ø)
think-resource 100.00% <ø> (ø)
think-router 100.00% <ø> (ø)
think-router-rest 93.93% <ø> (ø)
think-sequelize 47.84% <ø> (ø)
think-session 97.79% <ø> (ø)
think-session-cookie 97.63% <ø> (ø)
think-session-file 96.02% <ø> (ø)
think-session-jwt 100.00% <ø> (ø)
think-session-mysql 27.85% <ø> (ø)
think-session-redis 95.00% <ø> (ø)
think-store-file 87.67% <ø> (ø)
think-svg-captcha 100.00% <ø> (ø)
think-trace 60.25% <ø> (ø)
think-typescript 100.00% <ø> (ø)
think-validator 100.00% <ø> (ø)
think-view 56.11% <ø> (ø)
think-view-ejs 100.00% <ø> (ø)
think-view-handlebars 100.00% <ø> (ø)
think-view-nunjucks 100.00% <ø> (ø)
think-view-pug 100.00% <ø> (ø)
think-watcher 98.91% <ø> (ø)
think-websocket 100.00% <ø> (ø)
think-websocket-socket.io 100.00% <ø> (ø)
think-websocket-ws 0.00% <ø> (ø)
thinkjs 94.87% <ø> (ø)
Files with missing lines Coverage Δ
packages/think-helper/index.js 99.15% <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 3d23253...e61354e. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@lizheming
lizheming merged commit a494d16 into thinkjs:master Nov 4, 2026
80 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.

2 participants