Skip to content

Commit

Permalink
Fix unescaped special characters in minihtml (#2036)
Browse files Browse the repository at this point in the history
  • Loading branch information
jwortmann authored Aug 29, 2022
1 parent bd4e014 commit 5e6f49d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
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 "")
return ""


Expand Down

0 comments on commit 5e6f49d

Please sign in to comment.