Skip to content

Commit b84406e

Browse files
committed
fix(vcs): combine Mercurial URL validation policies
Keep the merged local-path scheme guard while rejecting revset fragments in the same runtime validator. Move the changelog entry below the shared insertion point. Discovered by Anthropic’s OSS Scanner, as vulnerability ANT-2026-GE21V5V5.
1 parent ab19d77 commit b84406e

2 files changed

Lines changed: 4 additions & 9 deletions

File tree

‎docs/changes.rst‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,6 @@ Weblate 2026.12
107107
* Disabled repository-controlled reStructuredText parser imports during Sphinx extraction and checks.
108108
* Kept the repository locked while the :ref:`addon-weblate.generate.generate` add-on writes files during installation.
109109
* Escaped template syntax in notification settings help built from project and component names.
110-
* Prevented :ref:`Mercurial <vcs-mercurial>` branch names and remote URL fragments from evaluating revsets that can contact arbitrary servers.
111110

112111
* Warn before and after restoring a :ref:`project backup <projectbackup>` when a public-only billing plan makes the project public.
113112

@@ -122,6 +121,7 @@ Weblate 2026.12
122121
* Removed internal filesystem paths and raw command output from gettext and script :ref:`add-on alerts <alerts>`.
123122
* Redacted remote source URLs from :ref:`JavaScript localization CDN <addon-weblate.cdn.cdnjs>` alerts and activity logs, including existing records.
124123
* Applied the destination project’s :ref:`access controls <access-control>` to component history after a move, and linked new category rename and move events to their category.
124+
* Prevented :ref:`Mercurial <vcs-mercurial>` branch names and remote URL fragments from evaluating revsets that can contact arbitrary servers.
125125

126126
* Required project management permission to change a component URL through the API and prevented :ref:`case-insensitive slug conflicts <component-slug>` from blocking repository cleanup.
127127
* Required the site-wide ``language.add`` permission to :http:post:`create a language through the REST API </api/languages/>`.

‎weblate/vcs/mercurial.py‎

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -99,13 +99,6 @@ def sanitize_error_message(errormessage: str) -> str:
9999
return match[1]
100100
return errormessage
101101

102-
@classmethod
103-
def validate_remote_url(cls, url: str) -> ResolvedRepositoryURL | None:
104-
# Mercurial treats URL fragments as revisions and evaluates revsets.
105-
if "#" in url:
106-
raise RepositoryValidationError(0, "repository_url_invalid")
107-
return super().validate_remote_url(url)
108-
109102
def is_valid(self) -> bool:
110103
"""Check whether this is a valid repository."""
111104
return os.path.exists(os.path.join(self.path, ".hg", "requires"))
@@ -202,7 +195,9 @@ def check_config(self) -> None:
202195

203196
@classmethod
204197
def validate_remote_url(cls, url: str) -> ResolvedRepositoryURL | None:
205-
"""Reject URLs that Mercurial interprets as local paths."""
198+
"""Reject URLs that Mercurial interprets as local paths or revsets."""
199+
if "#" in url:
200+
raise RepositoryValidationError(0, "repository_url_invalid")
206201
target = super().validate_remote_url(url)
207202
if urlparse(url).scheme and not url.startswith(cls.url_prefixes):
208203
raise RepositoryValidationError(0, "repository_url_parse_invalid")

0 commit comments

Comments
 (0)