Skip to content
Open
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
1 change: 1 addition & 0 deletions docs/changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ Weblate 2026.12
* Required recent browser verification to view or change :ref:`translation service configurations <machine-translation-setup>` or change exclusions.
* Removed internal filesystem paths and raw command output from gettext and script :ref:`add-on alerts <alerts>`.
* Redacted remote source URLs from :ref:`JavaScript localization CDN <addon-weblate.cdn.cdnjs>` alerts and activity logs, including existing records.
* Removed repository credentials from automatically generated Azure DevOps browser links.
* 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.
* Prevented :ref:`Mercurial <vcs-mercurial>` from interpreting repository file names as file patterns that could disclose server files.
* Prevented untrusted PO headers from changing the :ref:`merge driver <vcs>` fallback command when gettext tools are unavailable.
Expand Down
2 changes: 1 addition & 1 deletion weblate/trans/models/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@

AZURE_REPOS_REGEXP = [
r"(?:https):\/\/(?:dev.azure.com)\/([^/]*)\/([^/]*)\/(?:_git)\/([^/]*)",
r"(?:https):\/\/(?:([^/]*).visualstudio.com)\/([^/]*)\/(?:_git)\/([^/]*)",
r"(?:https):\/\/(?:[^/]*@)?([^/@:]+)\.visualstudio\.com\/([^/]*)\/(?:_git)\/([^/]*)",
r"(?:[^/]*)\@vs-ssh.visualstudio.com:v3\/([^/]*)\/([^/]*)\/([^/]*)",
r"(?:git@ssh.dev.azure.com:v3)\/([^/]*)\/([^/]*)\/([^/]*)",
]
Expand Down Expand Up @@ -2390,7 +2390,7 @@
# Calculate progress for translations
if progress is None:
self.translations_progress += 1
progress = 100 * self.translations_progress // self.translations_count

Check failure on line 2393 in weblate/trans/models/component.py

View workflow job for this annotation

GitHub Actions / mypy

Unsupported operand types for // ("int" and "None")
# ruff: ignore[import-outside-top-level]
from weblate.trans.repository_context import repository_task_progress_scope

Expand Down Expand Up @@ -2510,7 +2510,7 @@
if "source_translation" in self.__dict__:
return self.__dict__["source_translation"]
try:
result = self.translation_set.get(language_id=self.source_language_id)

Check failure on line 2513 in weblate/trans/models/component.py

View workflow job for this annotation

GitHub Actions / mypy

Incompatible type for lookup 'language_id': (got "int | None", expected "str | int")
except ObjectDoesNotExist:
return None
result.sync_readonly_check_flag()
Expand Down Expand Up @@ -2553,7 +2553,7 @@
)
except IntegrityError:
try:
result = self.translation_set.get(

Check failure on line 2556 in weblate/trans/models/component.py

View workflow job for this annotation

GitHub Actions / mypy

Incompatible type for lookup 'language_id': (got "int | None", expected "str | int")
language_id=self.source_language_id
)
except self.translation_set.model.DoesNotExist:
Expand Down Expand Up @@ -2591,7 +2591,7 @@
self, source: Unit, *, save: bool = True, user: User | None = None
) -> Change:
# Avoid fetching empty list of checks from the database
source.all_checks = []

Check failure on line 2594 in weblate/trans/models/component.py

View workflow job for this annotation

GitHub Actions / mypy

Incompatible types in assignment (expression has type "list[Never]", variable has type "QuerySet[Check, Check]")
source.source_updated = True
user = user or self.get_update_user(None)
change = source.generate_change(
Expand Down Expand Up @@ -5107,7 +5107,7 @@

def clear_prefetched_alerts(self) -> None:
with suppress(AttributeError, KeyError):
self._prefetched_objects_cache.pop("alert_set")

Check failure on line 5110 in weblate/trans/models/component.py

View workflow job for this annotation

GitHub Actions / mypy

"Component" has no attribute "_prefetched_objects_cache"

@property
def lock_alerts(self):
Expand Down Expand Up @@ -5412,7 +5412,7 @@
if self.has_template():
# Avoid parsing if template is invalid
try:
self.template_store.check_valid()

Check failure on line 5415 in weblate/trans/models/component.py

View workflow job for this annotation

GitHub Actions / mypy

Item "None" of "TranslationFormat[Any, Any, Any] | None" has no attribute "check_valid"
except (ValueError, FileParseError) as exc:
raise InvalidTemplateError(info=str(exc)) from exc
self._template_check_done = True
Expand Down Expand Up @@ -5472,7 +5472,7 @@
translation = self.source_translation

if self.is_gettext_po_template() and os.path.exists(
self.get_new_base_filename()

Check failure on line 5475 in weblate/trans/models/component.py

View workflow job for this annotation

GitHub Actions / mypy

Argument 1 to "exists" has incompatible type "str | None"; expected "int | str | bytes | PathLike[str] | PathLike[bytes]"
):
# Process template file as source to include additional metadata
matches = [self.new_base, *matches]
Expand Down Expand Up @@ -5541,7 +5541,7 @@
)
self.handle_parse_error(error.__cause__, filename=self.template)
self.update_import_alerts()
raise error.__cause__ from error # pylint: disable=raising-non-exception

Check failure on line 5544 in weblate/trans/models/component.py

View workflow job for this annotation

GitHub Actions / mypy

Exception must be derived from BaseException
was_change |= bool(translation.reason)
translations[translation.id] = translation
languages[lang.code] = translation
Expand Down Expand Up @@ -5995,7 +5995,7 @@
filename = self.get_new_base_filename()
template = self.has_template()
return self.file_format_cls.is_valid_base_for_new(
filename,

Check failure on line 5998 in weblate/trans/models/component.py

View workflow job for this annotation

GitHub Actions / mypy

Argument 1 to "is_valid_base_for_new" of "TranslationFormat" has incompatible type "str | None"; expected "str"
template,
errors,
fast=fast,
Expand Down Expand Up @@ -6023,7 +6023,7 @@
raise ValidationError({"new_base": message, "new_lang": message})
filename = self.get_new_base_filename()
# File is present, but does not exist
if not os.path.exists(filename):

Check failure on line 6026 in weblate/trans/models/component.py

View workflow job for this annotation

GitHub Actions / mypy

Argument 1 to "exists" has incompatible type "str | None"; expected "int | str | bytes | PathLike[str] | PathLike[bytes]"
raise ValidationError({"new_base": gettext("File does not exist.")})
# File is present, but it is not valid
if errors:
Expand Down
17 changes: 16 additions & 1 deletion weblate/trans/tests/test_component.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
from django.utils import timezone
from translate.storage.base import ParseError

from weblate.auth.models import setup_project_groups
from weblate.auth.models import get_anonymous, setup_project_groups
from weblate.checks.models import Check
from weblate.formats.ttkit import PoFormat
from weblate.formats.txt import AppStoreFormat, MultiparserError
Expand Down Expand Up @@ -5367,3 +5367,18 @@ def test_repo_link_generation_azure(self) -> None:
"https://dev.azure.com/f/c/_git/ATEST/blob/main/test.py#L42",
self.get_url(),
)

def test_repo_link_generation_azure_omits_credentials(self) -> None:
token = "test-token"
self.component.repo = f"https://user:{token}@f.visualstudio.com/c/_git/ATEST"
expected = "https://dev.azure.com/f/c/_git/ATEST/blob/main/test.py#L42"

self.assertEqual(self.get_url(), expected)
self.assertEqual(
self.component.get_repoweb_link("test.py", "42", user=get_anonymous()),
expected,
)
self.assertNotIn(token, expected)

self.component.repo = "https://dev.azure.com/f/c/_git/ATEST"
self.assertEqual(self.get_url(), expected)
Loading