fix(ui): escape special characters in description#1582
fix(ui): escape special characters in description#1582danielroe merged 2 commits intonpmx-dev:mainfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
2 Skipped Deployments
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
📝 WalkthroughWalkthroughTwo Vue components were changed to decode HTML entities when rendering package descriptions: in PackageSelector.vue and TableRow.vue the description rendering now wraps the source string with decodeHtmlEntities(...) instead of interpolating the raw string. No other control flow, DOM structure, or fallback values were altered. Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
app/components/Compare/PackageSelector.vue (1)
52-60:⚠️ Potential issue | 🔴 CriticalSame unsanitised
v-htmlXSS risk asTableRow.vue— fix at the data-mapping layer
result.descriptionoriginates fromfilteredResults(lines 52–60), which maps npm registry descriptions without any transformation. Binding this directly tov-htmlat line 309 carries the identical stored-XSS risk described forTableRow.vue.The cleanest fix is to decode HTML entities once, inside the
filteredResultscomputed, and revert the template to text interpolation:🔒 Proposed fix
const filteredResults = computed(() => { if (!searchData.value?.objects) return [] return searchData.value.objects .map(o => ({ name: o.package.name, - description: o.package.description, + description: o.package.description ? decodeEntities(o.package.description) : undefined, })) .filter(r => !packages.value.includes(r.name)) })- <span - v-if="result.description" - class="text-xs text-fg-muted truncate mt-0.5 w-full block" - v-html="result.description" - /> + <span + v-if="result.description" + class="text-xs text-fg-muted truncate mt-0.5 w-full block" + >{{ result.description }}</span>Where
decodeEntitiesis the shared utility proposed in theTableRow.vuecomment (usinghe.decodefor SSR compatibility).Also applies to: 306-310
🔗 Linked issue
Fixes: #1572
🧭 Context
I'm using the
decodeHtmlEntitiesto decode the HTML entities and render them📚 Description
This is the one that fixes the issue in Compare packages

and I also found another instance in the Search table row