This commit is contained in:
Martin Trigaux 2025-07-24 13:07:49 -04:00 committed by GitHub
commit 6800ead99d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 14 additions and 3 deletions

View file

@ -371,9 +371,7 @@ class Content:
def _get_intrasite_link_regex(self) -> re.Pattern:
intrasite_link_regex = self.settings["INTRASITE_LINK_REGEX"]
regex = rf"""
(?P<markup><[^\>]+ # match tag with all url-value attributes
(?:href|src|poster|data|cite|formaction|action|content)\s*=\s*)
(?P<markup>(?:href|src|poster|data|cite|formaction|action|content)\s*=\s*)
(?P<quote>["\']) # require value to be quoted
(?P<path>{intrasite_link_regex}(?P<value>.*?)) # the url value
(?P=quote)"""

View file

@ -532,6 +532,9 @@ class TestPage(TestBase):
"images/poster.jpg": Static(
"", settings=args["settings"], source_path="images/poster.jpg"
),
"images/placeholder.jpg": Static(
"", settings=args["settings"], source_path="images/placeholder.jpg"
),
}
args["context"]["generated_content"] = {
"article.rst": Article(
@ -560,6 +563,16 @@ class TestPage(TestBase):
content, '<img src="http://static.cool.site/images/poster.jpg"/>'
)
# Image with two links
args["content"] = (
'<img src="{static}/images/placeholder.jpg" data-src="{static}/images/poster.jpg"/>'
)
content = Page(**args).get_content("http://cool.site")
self.assertEqual(
content,
'<img src="http://static.cool.site/images/placeholder.jpg" data-src="http://static.cool.site/images/poster.jpg"/>',
)
# Image link will go to static
args["content"] = '<meta content="{static}/images/poster.jpg"/>'
content = Page(**args).get_content("http://cool.site")