Repository: sissbruecker/linkding
Pull request #625 (2024-02-07 17:40:30)

Bump django from 5.0.1 to 5.0.2
Bumps [django](https://github.com/django/django) from 5.0.1 to 5.0.2.
<details>
<summary>Commits</summary>
<ul>
<li><a href="https://github.com/django/django/commit/428d06ccef09e70bcef9869c5a9404863b2fc7d8"><code>428d06c</code></a> [5.0.x] Bumped version for 5.0.2 release.</li>
<li><a href="https://github.com/django/django/commit/16a8fe18a3b81250f4fa57e3f93f0599dc4895bc"><code>16a8fe1</code></a> [5.0.x] Fixed CVE-2024-24680 -- Mitigated potential DoS in intcomma template ...</li>
<li><a href="https://github.com/django/django/commit/2cfa3fba0c8c5f3cf5daf23fd5333902a34fea86"><code>2cfa3fb</code></a> [5.0.x] Changed severity levels to list in security policy docs.</li>
<li><a href="https://github.com/django/django/commit/761946f8e1b6d725f83fa4f3b04ca9750f486009"><code>761946f</code></a> [5.0.x] Fixed <a href="https://redirect.github.com/django/django/issues/35149">#35149</a> -- Fixed crashes of db_default with unresolvable output ...</li>
<li><a href="https://github.com/django/django/commit/914eee1a9bee7ae48e6b23ef905ec00bcc241791"><code>914eee1</code></a> [5.0.x] Refs <a href="https://redirect.github.com/django/django/issues/35149">#35149</a> -- Made equivalent db_default alterations noops.</li>
<li><a href="https://github.com/django/django/commit/3e7a30fb3a5ea38d06bbedd53e2130bf192425c7"><code>3e7a30f</code></a> [5.0.x] Fixed <a href="https://redirect.github.com/django/django/issues/35162">#35162</a> -- Fixed crash when adding fields with db_default on MySQL.</li>
<li><a href="https://github.com/django/django/commit/741f080ab595fa34ad0d682a096026abade0dcab"><code>741f080</code></a> [5.0.x] Fixed <a href="https://redirect.github.com/django/django/issues/35147">#35147</a> -- Added backward incompatibility note about filtering a...</li>
<li><a href="https://github.com/django/django/commit/58d5e5779c6b079f1a36e537a3fc2ebc446a721a"><code>58d5e57</code></a> [5.0.x] Fixed typo in docs/topics/db/managers.txt.</li>
<li><a href="https://github.com/django/django/commit/a8f9c29d4bf1387bf1ede03a173dd7bfed3e2ce0"><code>a8f9c29</code></a> [5.0.x] Removed mention of designers in DTL design philosophy.</li>
<li><a href="https://github.com/django/django/commit/06b05c748ff4079411b7e570311de879671399df"><code>06b05c7</code></a> [5.0.x] Refs <a href="https://redirect.github.com/django/django/issues/34936">#34936</a> -- Added test for altering DecimalField with db_default t...</li>
<li>Additional commits viewable in <a href="https://github.com/django/django/compare/5.0.1...5.0.2">compare view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=django&package-manager=pip&previous-version=5.0.1&new-version=5.0.2)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
You can disable automated security fix PRs for this repo from the [Security Alerts page](https://github.com/sissbruecker/linkding/network/alerts).

</details>


Patch:
diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml
index 5e7a896..5bddff2 100644
--- a/.github/workflows/main.yaml
+++ b/.github/workflows/main.yaml
@@ -1,6 +1,6 @@
 name: linkding CI
 
-on: [push]
+on: [push, pull_request]
 
 jobs:
   unit_tests:
diff --git a/bookmarks/views/partials/contexts.py b/bookmarks/views/partials/contexts.py
index 998f038..700a74d 100644
--- a/bookmarks/views/partials/contexts.py
+++ b/bookmarks/views/partials/contexts.py
@@ -1,5 +1,6 @@
 import urllib.parse
 from typing import Set, List
+import re
 
 from django.core.handlers.wsgi import WSGIRequest
 from django.core.paginator import Paginator
@@ -11,13 +12,13 @@ from bookmarks import utils
 from bookmarks.models import (
     Bookmark,
     BookmarkSearch,
-    BookmarkSearchForm,
     User,
     UserProfile,
     Tag,
 )
 
 DEFAULT_PAGE_SIZE = 30
+CJK_RE = re.compile(r"[\u4e00-\u9fff]+")
 
 
 class BookmarkItem:
@@ -123,13 +124,13 @@ class BookmarkListContext:
         )
 
     def get_base_url(self):
-        raise Exception(f"Must be implemented by subclass")
+        raise Exception("Must be implemented by subclass")
 
     def get_base_action_url(self):
-        raise Exception(f"Must be implemented by subclass")
+        raise Exception("Must be implemented by subclass")
 
     def get_bookmark_query_set(self):
-        raise Exception(f"Must be implemented by subclass")
+        raise Exception("Must be implemented by subclass")
 
 
 class ActiveBookmarkListContext(BookmarkListContext):
@@ -178,23 +179,33 @@ class TagGroup:
         self.tags = []
         self.char = char
 
+    def __repr__(self):
+        return f"<{self.char} TagGroup>"
+
     @staticmethod
     def create_tag_groups(tags: Set[Tag]):
         # Ensure groups, as well as tags within groups, are ordered alphabetically
         sorted_tags = sorted(tags, key=lambda x: str.lower(x.name))
         group = None
         groups = []
+        cjk_used = False
+        cjk_group = TagGroup("Ideographic")
 
         # Group tags that start with a different character than the previous one
         for tag in sorted_tags:
             tag_char = tag.name[0].lower()
-
-            if not group or group.char != tag_char:
+            if CJK_RE.match(tag_char):
+                cjk_used = True
+                cjk_group.tags.append(tag)
+            elif not group or group.char != tag_char:
                 group = TagGroup(tag_char)
                 groups.append(group)
+                group.tags.append(tag)
+            else:
+                group.tags.append(tag)
 
-            group.tags.append(tag)
-
+        if cjk_used:
+            groups.append(cjk_group)
         return groups
 
 
@@ -224,7 +235,7 @@ class TagCloudContext:
         self.has_selected_tags = has_selected_tags
 
     def get_tag_query_set(self):
-        raise Exception(f"Must be implemented by subclass")
+        raise Exception("Must be implemented by subclass")
 
     def get_selected_tags(self, tags: List[Tag]):
         parsed_query = queries.parse_query_string(self.search.q)
diff --git a/requirements.dev.txt b/requirements.dev.txt
index c7bdcc8..7d4b749 100644
--- a/requirements.dev.txt
+++ b/requirements.dev.txt
@@ -12,7 +12,7 @@ click==8.1.7
     # via black
 coverage==7.4.1
     # via -r requirements.dev.in
-django==5.0.1
+django==5.0.2
     # via
     #   django-appconf
     #   django-debug-toolbar
diff --git a/requirements.txt b/requirements.txt
index 4e8081d..bea3c7e 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -20,7 +20,7 @@ click==8.1.7
     # via waybackpy
 confusable-homoglyphs==3.2.0
     # via django-registration
-django==5.0.1
+django==5.0.2
     # via
     #   -r requirements.in
     #   django-registration


Test patch:
diff --git a/bookmarks/tests/test_tag_cloud_template.py b/bookmarks/tests/test_tag_cloud_template.py
index ca257a3..2ac61e0 100644
--- a/bookmarks/tests/test_tag_cloud_template.py
+++ b/bookmarks/tests/test_tag_cloud_template.py
@@ -39,7 +39,7 @@ class TagCloudTemplateTest(TestCase, BookmarkFactoryMixin, HtmlTestMixin):
             group_element = group_elements[group_index]
             link_elements = group_element.select("a")
 
-            self.assertEqual(len(link_elements), len(tags))
+            self.assertEqual(len(link_elements), len(tags), tags)
 
             for tag_index, tag in enumerate(tags, start=0):
                 link_element = link_elements[tag_index]
@@ -50,6 +50,59 @@ class TagCloudTemplateTest(TestCase, BookmarkFactoryMixin, HtmlTestMixin):
         link_elements = soup.select("p.selected-tags a")
         self.assertEqual(len(link_elements), count)
 
+    def test_cjk_using_single_group(self):
+        """
+        Ideographic characters will be using the same group
+        While other japanese and korean characters will have separate groups.
+        """
+        tags = [
+            self.setup_tag(name="Aardvark"),
+            self.setup_tag(name="Armadillo"),
+            self.setup_tag(name="あひる"),
+            self.setup_tag(name="あきらか"),
+            self.setup_tag(name="アヒル"),
+            self.setup_tag(name="アキラカ"),
+            self.setup_tag(name="ひる"),
+            self.setup_tag(name="アヒル"),
+            self.setup_tag(name="오리"),
+            self.setup_tag(name="물"),
+            self.setup_tag(name="家鴨"),
+            self.setup_tag(name="感じ"),
+        ]
+        self.setup_bookmark(tags=tags)
+        rendered_template = self.render_template()
+
+        self.assertTagGroups(
+            rendered_template,
+            [
+                [
+                    "Aardvark",
+                    "Armadillo",
+                ],
+                [
+                    "あきらか",
+                    "あひる",
+                ],
+                [
+                    "ひる",
+                ],
+                [
+                    "アキラカ",
+                    "アヒル",
+                ],
+                [
+                    "물",
+                ],
+                [
+                    "오리",
+                ],
+                [
+                    "家鴨",
+                    "感じ",
+                ],
+            ],
+        )
+
     def test_group_alphabetically(self):
         tags = [
             self.setup_tag(name="Cockatoo"),