Skip to content

Commit

Permalink
Merge pull request #2657 from digitalfabrik/develop
Browse files Browse the repository at this point in the history
Release `2024.2.1`
  • Loading branch information
timobrembeck authored Feb 12, 2024
2 parents 46bfc49 + 3d37de8 commit b54455d
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 17 deletions.
25 changes: 9 additions & 16 deletions integreat_cms/cms/forms/linkcheck/edit_url_form.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
from django.core.validators import EmailValidator, URLValidator
from django.utils.translation import gettext_lazy as _

if TYPE_CHECKING:
from django.core.validators import URLValidator

logger = logging.getLogger(__name__)


Expand All @@ -19,7 +16,7 @@ class LinkField(forms.URLField):
"""

#: Disable the default URL validator
default_validators: list[URLValidator] = []
default_validators: list[URLValidator | EmailValidator] = []
#: Whether to skip the validation URL fragments in URLField.to_python()
skip_url_fragment_validation: bool = True

Expand All @@ -36,10 +33,8 @@ def to_python(self, value: str) -> str:
"Value %r is a mailto or tel link, skipping to_python() of URLField.",
value,
)
value = super(forms.URLField, self).to_python(value)
else:
value = super().to_python(value)
return value
return super(forms.URLField, self).to_python(value)
return super().to_python(value)

def clean(self, value: str) -> str:
"""
Expand All @@ -58,14 +53,12 @@ def clean(self, value: str) -> str:
)
self.validators.append(EmailValidator())
self.error_messages["invalid"] = _("Enter a valid email address.")
value = f"mailto:{super().clean(email)}"
else:
if not value.startswith("tel:"):
logger.debug("Value %r is a normal link, enforcing URLValidator", value)
self.validators.append(URLValidator())
self.skip_url_fragment_validation = False
value = super().clean(value)
return value
return f"mailto:{super().clean(email)}"
if not value.startswith("tel:"):
logger.debug("Value %r is a normal link, enforcing URLValidator", value)
self.validators.append(URLValidator(schemes=["http", "https"]))
self.skip_url_fragment_validation = False
return super().clean(value)


class EditUrlForm(forms.Form):
Expand Down
3 changes: 3 additions & 0 deletions integreat_cms/cms/utils/linkcheck_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,9 @@ def replace_links(
logger.debug(
"Replacing %r with %r in %r", url, fixed_url, translation
)
new_translation.content = fix_content_link_encoding(
new_translation.content
)
if new_translation.content != translation.content and commit:
save_new_version(translation, new_translation, user)
# Wait until all post-save signals have been processed
Expand Down
5 changes: 4 additions & 1 deletion integreat_cms/cms/views/linkcheck/linkcheck_list_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

from ...decorators import permission_required
from ...forms.linkcheck.edit_url_form import EditUrlForm
from ...utils.linkcheck_utils import filter_urls, get_urls
from ...utils.linkcheck_utils import filter_urls, fix_content_link_encoding, get_urls

if TYPE_CHECKING:
from typing import Any
Expand Down Expand Up @@ -171,6 +171,9 @@ def post(self, request: HttpRequest, *args: Any, **kwargs: Any) -> HttpResponse:
new_translation.content,
partial(self.replace_link, self.instance.url, new_url),
)
new_translation.content = fix_content_link_encoding(
new_translation.content
)
# Save translation with replaced content as new minor version
new_translation.id = None
new_translation.version += 1
Expand Down
2 changes: 2 additions & 0 deletions integreat_cms/release_notes/current/unreleased/2646.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
en: Allow the central link replacement of URLs with UTF-8 characters in the domain name
de: Erlaube das zentrale Ersetzen von URLs mit UTF-8 Zeichen im Domainnamen im Link-Checker

0 comments on commit b54455d

Please sign in to comment.