Skip to content

Commit

Permalink
fix: Parse 'hlink://' URIs as proper URIs
Browse files Browse the repository at this point in the history
  • Loading branch information
Wuestengecko committed Nov 8, 2024
1 parent f2d94ec commit 4fb52d3
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions capellambse/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import sys
import time
import typing as t
import urllib.parse

import lxml.html
import markupsafe
Expand Down Expand Up @@ -546,16 +547,18 @@ def replace_hlinks(
"""

def cb(el: etree._Element) -> None:
if (
el.tag != "a"
or "href" not in el.attrib
or not el.attrib["href"].startswith("hlink://")
):
if el.tag != "a" or "href" not in el.attrib:
return
target = el.attrib["href"][8:]

try:
obj = model.by_uuid(target)
url = urllib.parse.urlparse(el.attrib["href"])
except ValueError:
return
if url.scheme != "hlink":
return

try:
obj = model.by_uuid(url.netloc)
except KeyError:
pass
else:
Expand Down

0 comments on commit 4fb52d3

Please sign in to comment.