Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 5 additions & 10 deletions docksec/docker_scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -1302,24 +1302,19 @@ def _escape_html(self, text: str) -> str:
"""
Escape HTML special characters in text.

Uses Python's built-in html.escape() for complete HTML5
entity handling, replacing the previous hand-rolled table.

Args:
text: Text to escape

Returns:
HTML-escaped text
"""
import html
if not text:
return ""

html_escape_table = {
"&": "&",
'"': """,
"'": "'",
">": ">",
"<": "&lt;",
}

return "".join(html_escape_table.get(c, c) for c in str(text))
return html.escape(str(text), quote=True)

def main():
"""Main function to run the security scanner."""
Expand Down
15 changes: 5 additions & 10 deletions docksec/report_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -458,24 +458,19 @@ def _escape_html(self, text: str) -> str:
"""
Escape HTML special characters in text.

Uses Python's built-in html.escape() for complete HTML5
entity handling, replacing the previous hand-rolled table.

Args:
text: Text to escape

Returns:
HTML-escaped text
"""
import html
if not text:
return ""

html_escape_table = {
"&": "&amp;",
'"': "&quot;",
"'": "&#x27;",
">": "&gt;",
"<": "&lt;",
}

return "".join(html_escape_table.get(c, c) for c in str(text))
return html.escape(str(text), quote=True)

def _count_by_severity(self, vulnerabilities: List[Dict]) -> Dict[str, int]:
"""
Expand Down
Loading