diff --git a/bookmarks/services/importer.py b/bookmarks/services/importer.py index 41fda08..50acaeb 100644 --- a/bookmarks/services/importer.py +++ b/bookmarks/services/importer.py @@ -96,6 +96,13 @@ def _create_missing_tags(netscape_bookmarks: List[NetscapeBookmark], user: User) for netscape_bookmark in netscape_bookmarks: for tag_name in netscape_bookmark.tag_names: + # Skip tag names that exceed the maximum allowed length + if len(tag_name) > 64: + logger.warning( + f"Ignoring tag '{tag_name}' (length {len(tag_name)}) as it exceeds maximum length of 64 characters" + ) + continue + tag = tag_cache.get(tag_name) if not tag: tag = Tag(name=tag_name, owner=user) diff --git a/bookmarks/tests/test_importer.py b/bookmarks/tests/test_importer.py index 996e9b9..49949b3 100644 --- a/bookmarks/tests/test_importer.py +++ b/bookmarks/tests/test_importer.py @@ -366,6 +366,32 @@ class ImporterTestCase(TestCase, BookmarkFactoryMixin, ImportTestMixin): self.assertListEqual(tag_names, ["tag-1", "tag-2", "tag-3"]) + def test_ignore_long_tag_names(self): + long_tag = "a" * 65 + valid_tag = "valid-tag" + + test_html = self.render_html( + tags_html=f""" +