Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strip html tags from title #1801

Merged
merged 2 commits into from
Mar 3, 2023
Merged

Strip html tags from title #1801

merged 2 commits into from
Mar 3, 2023

Conversation

pavel-karatsiuba
Copy link
Contributor

Strip HTML tags from the title to avoid HTML tags in the search results

fix: #1797

src/util/misc.ts Fixed Show fixed Hide fixed
@codecov
Copy link

codecov bot commented Mar 1, 2023

Codecov Report

Patch coverage: 100.00% and no project coverage change

Comparison is base (ad56c6b) 70.42% compared to head (befdeda) 70.42%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1801   +/-   ##
=======================================
  Coverage   70.42%   70.42%           
=======================================
  Files          23       23           
  Lines        2597     2597           
  Branches      594      595    +1     
=======================================
  Hits         1829     1829           
  Misses        661      661           
  Partials      107      107           
Impacted Files Coverage Δ
src/util/misc.ts 72.35% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

Copy link
Collaborator

@kelson42 kelson42 left a comment

Choose a reason for hiding this comment

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

Please create a unit test for this and test the special cases.

src/util/misc.ts Outdated
@@ -283,7 +283,7 @@ export function getStrippedTitleFromHtml(html: string) {
const doc = domino.createDocument(html)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm choqued by this line which is super CPU expensive. There is no way we coukd do that quicker?! I know this is not the topic of this PR, but stil...

}
return title.replace(/<[^>]*>?/gm, '')

Check failure

Code scanning / CodeQL

Incomplete multi-character sanitization

This string may still contain [<script](1), which may cause an HTML element injection vulnerability.
kelson42

This comment was marked as resolved.

@kelson42 kelson42 merged commit 10dbdaf into main Mar 3, 2023
@kelson42 kelson42 deleted the strip-html-in-title branch March 3, 2023 11:51
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.

Search result returns text with formatting code
2 participants