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

Fix unescaped special characters in minihtml #2036

Merged
merged 1 commit into from
Aug 29, 2022
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
3 changes: 2 additions & 1 deletion plugin/hover.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
from .session_view import HOVER_HIGHLIGHT_KEY
from urllib.parse import unquote, urlparse
import functools
import html
import re
import sublime
import webbrowser
Expand Down Expand Up @@ -224,7 +225,7 @@ def _on_all_document_links_resolved(
title = link.get("tooltip") or "Follow link"
if title != "Follow link":
link_has_standard_tooltip = False
contents.append('<a href="{}">{}</a>'.format(target, title))
contents.append('<a href="{}">{}</a>'.format(html.escape(target), html.escape(title)))
if len(contents) > 1:
link_has_standard_tooltip = False
link_range = range_to_region(Range.from_lsp(links[0]["range"]), self.view) if links else None
Expand Down
4 changes: 2 additions & 2 deletions plugin/inlay_hint.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ def get_inlay_hint_html(view: sublime.View, inlay_hint: InlayHint, session: Sess

def format_inlay_hint_tooltip(tooltip: Optional[Union[str, MarkupContent]]) -> str:
if isinstance(tooltip, str):
return tooltip
return html.escape(tooltip)
if isinstance(tooltip, dict): # MarkupContent
return tooltip.get('value') or ""
return html.escape(tooltip.get('value') or "")
rchl marked this conversation as resolved.
Show resolved Hide resolved
return ""


Expand Down