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

Update search.js to fix escaping problem #889

Merged
merged 1 commit into from
Dec 9, 2024

Conversation

Jelle-DIVD
Copy link
Contributor

Key changes made to fix the escaping issues:

  • Added proper JSON escaping using the jsonify filter for CVE titles and content: "title": {{ cve[1]["containers"]["cna"]["title"] | jsonify }},
  • Pre-processed the descriptions array before rendering: {% assign descriptions = cve[1]["containers"]["cna"]["descriptions"] | where: "lang", "en" | map: "value" %} "content": {{ descriptions | join: " " | jsonify }},
  • Cleaned up the overall code structure to be more consistent with proper comma handling between objects

The jsonify filter will properly escape all special characters, quotes, and code blocks in the content, preventing the JavaScript syntax errors you're seeing. This should resolve the HTML escaping issues while maintaining the search functionality.

Key changes made to fix the escaping issues:

- Added proper JSON escaping using the jsonify filter for CVE titles and content:
  `"title": {{ cve[1]["containers"]["cna"]["title"] | jsonify }},`
- Pre-processed the descriptions array before rendering:
`{% assign descriptions = cve[1]["containers"]["cna"]["descriptions"] | where: "lang", "en" | map: "value" %}
"content": {{ descriptions | join: " " | jsonify }},`
- Cleaned up the overall code structure to be more consistent with proper comma handling between objects

The jsonify filter will properly escape all special characters, quotes, and code blocks in the content, preventing the JavaScript syntax errors you're seeing. This should resolve the HTML escaping issues while maintaining the search functionality.
Copy link
Contributor

@MrSeccubus MrSeccubus left a comment

Choose a reason for hiding this comment

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

Thanks for the fixes, buddy.

@MrSeccubus MrSeccubus merged commit e38531f into DIVD-NL:main Dec 9, 2024
2 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