Skip to content

fix: strip HTML tags from plaintext search result descriptions - #1702

Merged
danielroe merged 2 commits into
mainfrom
serhalp/fix-search-dropdown
Feb 27, 2026
Merged

fix: strip HTML tags from plaintext search result descriptions#1702
danielroe merged 2 commits into
mainfrom
serhalp/fix-search-dropdown

Conversation

@serhalp

@serhalpserhalp commented Feb 27, 2026

Copy link
Copy Markdown
Member

🔗 Linked issue

Fixes#1681

🧭 Context

Probably a regression from #1582

📚 Description

After decoding HTML entities, descriptions containing entity-encoded HTML (e.g. <a>) were displaying reconstructed tags as raw text. Apply stripHtmlTags after decodeHtmlEntities in PackageSelector and TableRow components.

Screenshot 2026-02-27 at 09 00 42

After decoding HTML entities, descriptions containing entity-encoded
HTML (e.g. <a>) were displaying reconstructed tags as raw text.
Apply stripHtmlTags after decodeHtmlEntities in PackageSelector and
TableRow components.
Fixes#1681
@vercel

vercelBot commented Feb 27, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

ProjectDeploymentActionsUpdated (UTC)
npmx.devReadyReadyPreview, CommentFeb 27, 2026 2:31pm
2 Skipped Deployments
ProjectDeploymentActionsUpdated (UTC)
docs.npmx.devIgnoredIgnoredPreviewFeb 27, 2026 2:31pm
npmx-lunariaIgnoredIgnoredFeb 27, 2026 2:31pm

Request Review

Comment threadshared/utils/html.ts Fixed
@codecov

codecovBot commented Feb 27, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 88.88889% with 1 line in your changes missing coverage. Please review.
✅ All tests successful. No failed tests found.

Files with missing linesPatch %Lines
app/components/Compare/PackageSelector.vue0.00%1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@serhalp
serhalp marked this pull request as ready for review February 27, 2026 14:02
@coderabbitai

coderabbitaiBot commented Feb 27, 2026

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a76bd69 and 6dbc417.

📒 Files selected for processing (2)
  • server/utils/readme.ts
  • shared/utils/html.ts

📝 Walkthrough

Walkthrough

This change adds an exported stripHtmlTags(text: string): string to shared/utils/html.ts, updates components (app/components/Compare/PackageSelector.vue and app/components/Package/TableRow.vue) to render descriptions by first decoding HTML entities then stripping HTML tags, replaces a local stripHtmlTags in server/utils/readme.ts with the shared implementation, and adds unit tests covering stripHtmlTags and combined decoding+stripping behaviour.

Possibly related PRs

Suggested reviewers

  • 43081j
🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check nameStatusExplanation
Description check✅ PassedThe PR description clearly explains the bug fix: preventing raw HTML rendering in search results by stripping HTML tags after decoding entities.
Linked Issues check✅ PassedThe PR directly addresses issue #1681 by implementing the stripHtmlTags function and applying it in PackageSelector and TableRow components to prevent raw HTML rendering.
Out of Scope Changes check✅ PassedAll changes are focused on the core objective: refactoring shared HTML utility functions and applying stripHtmlTags to search result descriptions. No unrelated modifications detected.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch serhalp/fix-search-dropdown

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitaicoderabbitaiBot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
test/unit/shared/utils/html.spec.ts (1)

47-50: Add a regression test for decoded comparison text (non-tags).

Please include a case where < / > represent plain text operators, so we guard against accidental content removal.

Suggested test addition
 describe('stripHtmlTags', () => {
+ it('preserves decoded angle-bracket text when it is not an HTML tag', () => {+ const raw = '1 &lt; 2 &amp;&amp; 3 &gt; 1'+ expect(stripHtmlTags(decodeHtmlEntities(raw))).toBe('1 < 2 && 3 > 1')+ })+
it('works with decodeHtmlEntities to clean descriptions', () => {
const raw = '&lt;a href=&quot;url&quot;&gt;link&lt;/a&gt; and text'
expect(stripHtmlTags(decodeHtmlEntities(raw))).toBe('link and text')
})
})

ℹ️ Review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 71eba9d and a76bd69.

📒 Files selected for processing (4)
  • app/components/Compare/PackageSelector.vue
  • app/components/Package/TableRow.vue
  • shared/utils/html.ts
  • test/unit/shared/utils/html.spec.ts

Comment threadshared/utils/html.ts Outdated
Comment threadshared/utils/html.ts
@danielroe
danielroe added this pull request to the merge queueFeb 27, 2026
Merged via the queue into main with commit 5e3b034Feb 27, 2026
21 checks passed
@danielroe
danielroe deleted the serhalp/fix-search-dropdown branch February 27, 2026 14:46
class="py-2 px-3 text-sm text-fg-muted max-w-xs truncate"
>
{{ decodeHtmlEntities(pkg.description || '-') }}
{{ stripHtmlTags(decodeHtmlEntities(pkg.description || '-')) }}

@vmrjnvcvmrjnvcFeb 27, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

now with this changes there could be full empty descriptions displayed, but there should be dash if there is no description

Image

so correct should be {{ stripHtmlTags(decodeHtmlEntities(pkg.description || '')) || '-'}} because if there is just html in the description, all will be removed and we don't have fallback

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch! would you like to open a quick PR for that? 🙏🏼

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure, no problem!

here #1763

Sign up for freeto 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.

Raw HTML rendering in search results

4 participants

@serhalp@danielroe@github-advanced-security@vmrjnvc