-
-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[fc] Repository: plone.app.linkintegrity
Branch: refs/heads/master Date: 2024-05-14T19:55:52+02:00 Author: Paul Grunewald (pgrunewald) <paul.grunewald@tu-dresden.de> Commit: plone/plone.app.linkintegrity@3d2a436 Fix potential issue calculating breaches with objects sharing the same prefix Files changed: A news/97.bugfix M plone/app/linkintegrity/browser/info.py M plone/app/linkintegrity/tests/test_references.py Repository: plone.app.linkintegrity Branch: refs/heads/master Date: 2024-05-25T12:24:43-07:00 Author: David Glick (davisagli) <david.glick@plone.org> Commit: plone/plone.app.linkintegrity@bbf124e Merge pull request #104 from plone/fix_97 Fix potential issue calculating breaches with objects sharing the same prefix Files changed: A news/97.bugfix M plone/app/linkintegrity/browser/info.py M plone/app/linkintegrity/tests/test_references.py
- Loading branch information
Showing
1 changed file
with
19 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,63 +1,36 @@ | ||
Repository: plone.app.registry | ||
Repository: plone.app.linkintegrity | ||
|
||
|
||
Branch: refs/heads/master | ||
Date: 2024-05-09T15:53:32+02:00 | ||
Author: szakitibi (szakitibi) <szakitibi@users.noreply.github.com> | ||
Commit: https://github.com/plone/plone.app.registry/commit/7980a1386eae6c7d130726223f78324f3b257750 | ||
Date: 2024-05-14T19:55:52+02:00 | ||
Author: Paul Grunewald (pgrunewald) <paul.grunewald@tu-dresden.de> | ||
Commit: https://github.com/plone/plone.app.linkintegrity/commit/3d2a436b11960dd5a37c0b01b02b8b2c6f9960ab | ||
|
||
Remove duplicate "content" id | ||
Fix potential issue calculating breaches with objects sharing the same prefix | ||
|
||
Files changed: | ||
M plone/app/registry/browser/templates/records.pt | ||
A news/97.bugfix | ||
M plone/app/linkintegrity/browser/info.py | ||
M plone/app/linkintegrity/tests/test_references.py | ||
|
||
b'diff --git a/plone/app/registry/browser/templates/records.pt b/plone/app/registry/browser/templates/records.pt\nindex 5850bd7..41f6a81 100644\n--- a/plone/app/registry/browser/templates/records.pt\n+++ b/plone/app/registry/browser/templates/records.pt\n@@ -17,7 +17,7 @@\n </metal:block>\n \n <body>\n- <article id="content"\n+ <metal:main\n metal:fill-slot="prefs_configlet_main"\n tal:define="\n records view/records;\n@@ -251,6 +251,6 @@\n </div>\n </div>\n </div>\n- </article>\n+ </metal:main>\n </body>\n </html>\n' | ||
b'diff --git a/news/97.bugfix b/news/97.bugfix\nnew file mode 100644\nindex 0000000..ed4ac8f\n--- /dev/null\n+++ b/news/97.bugfix\n@@ -0,0 +1,2 @@\n+Fix potential issue calculating breaches with objects sharing the same prefix\n+[pgrunewald]\n\\ No newline at end of file\ndiff --git a/plone/app/linkintegrity/browser/info.py b/plone/app/linkintegrity/browser/info.py\nindex 4f6df41..41d7e35 100644\n--- a/plone/app/linkintegrity/browser/info.py\n+++ b/plone/app/linkintegrity/browser/info.py\n@@ -64,6 +64,8 @@ def get_breaches(self, items=None):\n # list of uids that are ignored\n uids_to_ignore.update([i.UID for i in brains_to_delete])\n \n+ excluded_paths = set(path2obj.keys())\n+\n # determine breaches\n for obj_path, obj in path2obj.items():\n brains_to_delete = path2brains[obj_path]\n@@ -77,7 +79,7 @@ def get_breaches(self, items=None):\n continue\n # look into potential breach\n breach = self.check_object(\n- obj=obj_to_delete, excluded_paths=set(path2obj.keys())\n+ obj=obj_to_delete, excluded_paths=excluded_paths\n )\n if breach:\n for source in breach["sources"]:\n@@ -134,7 +136,8 @@ def check_object(self, obj, excluded_path=None, excluded_paths=None):\n continue\n if any(\n [\n- source_path.startswith(excluded_path)\n+ source_path == excluded_path\n+ or source_path.startswith(excluded_path + "/")\n for excluded_path in excluded_paths\n ]\n ):\ndiff --git a/plone/app/linkintegrity/tests/test_references.py b/plone/app/linkintegrity/tests/test_references.py\nindex 1afb921..945b6cd 100644\n--- a/plone/app/linkintegrity/tests/test_references.py\n+++ b/plone/app/linkintegrity/tests/test_references.py\n@@ -278,3 +278,40 @@ def test_sources_with_multiple_links_can_appear_multiple_times(self):\n view = self.portal.restrictedTraverse("@@delete_confirmation_info")\n # deleting the two referenced document results in two reported breaches\n self.assertEqual(len(view.get_breaches([doc1, doc2])), 2)\n+\n+ def test_if_breaches_under_excluded_paths_are_ignored(self):\n+ """Test, if breaches are ignored under certain conditions."""\n+ folder_containing_doc4 = self.portal.folder1\n+ doc4 = self.portal.folder1.doc4\n+ doc1 = self.portal.doc1\n+ set_text(doc4, \'<a href="doc1">d1</a>\')\n+ # sanity check: deleting doc1 causes one breach\n+ doc4_breaches = {r.to_object for r in getOutgoingLinks(doc4)}\n+ self.assertEqual({doc1}, doc4_breaches)\n+ view = self.portal.restrictedTraverse("@@delete_confirmation_info")\n+ self.assertEqual(len(view.get_breaches([doc1])), 1)\n+ # now check for other ways, that should do not produce any breach:\n+ # a) we delete the document that links to doc1\n+ self.assertEqual(len(view.get_breaches([doc1, doc4])), 0)\n+ # b) we delete the folder, containing the document that links to doc1\n+ self.assertEqual(len(view.get_breaches([doc1, folder_containing_doc4])), 0)\n+\n+ def test_if_same_prefix_and_breaches_work(self):\n+ """Verify that the same prefix does not lead to acciddental ignored\n+ links / breaches.\n+ """\n+ from plone.app.linkintegrity.testing import create\n+\n+ doc1 = self.portal.doc1\n+ my_page = create(self.portal, "Document", id="my-page", title="My page")\n+ my_page2 = create(\n+ self.portal,\n+ "Document",\n+ id="my-page-being-linked",\n+ title="My Page Being Linked",\n+ )\n+ # Create a link, that might be overlooked since both page\' ids start\n+ # with the same string ("my-page").\n+ set_text(doc1, \'<a href="my-page-being-linked">.</a>\')\n+ view = self.portal.restrictedTraverse("@@delete_confirmation_info")\n+ self.assertEqual(len(view.get_breaches([my_page, my_page2])), 1)\n' | ||
|
||
Repository: plone.app.registry | ||
Repository: plone.app.linkintegrity | ||
|
||
|
||
Branch: refs/heads/master | ||
Date: 2024-05-17T07:57:18+02:00 | ||
Author: Tibor Szakmany () <szakmany@interaktiv.de> | ||
Commit: https://github.com/plone/plone.app.registry/commit/0f2a2f36935552c4036d5413db5b5fff438b0bbd | ||
Date: 2024-05-25T12:24:43-07:00 | ||
Author: David Glick (davisagli) <david.glick@plone.org> | ||
Commit: https://github.com/plone/plone.app.linkintegrity/commit/bbf124e601cd3f0d3834904043fd4ca4ab45e355 | ||
|
||
autoformat files | ||
Merge pull request #104 from plone/fix_97 | ||
|
||
Files changed: | ||
M plone/app/registry/browser/templates/records.pt | ||
|
||
b'diff --git a/plone/app/registry/browser/templates/records.pt b/plone/app/registry/browser/templates/records.pt\nindex 41f6a81..f5c486c 100644\n--- a/plone/app/registry/browser/templates/records.pt\n+++ b/plone/app/registry/browser/templates/records.pt\n@@ -17,11 +17,10 @@\n </metal:block>\n \n <body>\n- <metal:main\n- metal:fill-slot="prefs_configlet_main"\n- tal:define="\n- records view/records;\n- "\n+ <metal:main metal:fill-slot="prefs_configlet_main"\n+ tal:define="\n+ records view/records;\n+ "\n >\n \n <header>\n' | ||
|
||
Repository: plone.app.registry | ||
|
||
|
||
Branch: refs/heads/master | ||
Date: 2024-05-17T08:01:34+02:00 | ||
Author: Tibor Szakmany () <szakmany@interaktiv.de> | ||
Commit: https://github.com/plone/plone.app.registry/commit/fd5b53067c0a8c07e207b7be6e686f7e945d4062 | ||
|
||
add change log | ||
|
||
Files changed: | ||
A news/84.bugfix | ||
|
||
b'diff --git a/news/84.bugfix b/news/84.bugfix\nnew file mode 100644\nindex 0000000..66b0604\n--- /dev/null\n+++ b/news/84.bugfix\n@@ -0,0 +1,2 @@\n+Removes duplicate `<article id="content">`\n+[@szakitibi]\n\\ No newline at end of file\n' | ||
|
||
Repository: plone.app.registry | ||
|
||
|
||
Branch: refs/heads/master | ||
Date: 2024-05-22T17:46:13-07:00 | ||
Author: David Glick (davisagli) <dglick@gmail.com> | ||
Commit: https://github.com/plone/plone.app.registry/commit/1189b15118ae50779ccb01533eaab3b909b51a6f | ||
|
||
Merge pull request #84 from szakitibi/patch-1 | ||
|
||
Remove duplicate "content" id | ||
Fix potential issue calculating breaches with objects sharing the same prefix | ||
|
||
Files changed: | ||
A news/84.bugfix | ||
M plone/app/registry/browser/templates/records.pt | ||
A news/97.bugfix | ||
M plone/app/linkintegrity/browser/info.py | ||
M plone/app/linkintegrity/tests/test_references.py | ||
|
||
b'diff --git a/news/84.bugfix b/news/84.bugfix\nnew file mode 100644\nindex 0000000..66b0604\n--- /dev/null\n+++ b/news/84.bugfix\n@@ -0,0 +1,2 @@\n+Removes duplicate `<article id="content">`\n+[@szakitibi]\n\\ No newline at end of file\ndiff --git a/plone/app/registry/browser/templates/records.pt b/plone/app/registry/browser/templates/records.pt\nindex 5850bd7..f5c486c 100644\n--- a/plone/app/registry/browser/templates/records.pt\n+++ b/plone/app/registry/browser/templates/records.pt\n@@ -17,11 +17,10 @@\n </metal:block>\n \n <body>\n- <article id="content"\n- metal:fill-slot="prefs_configlet_main"\n- tal:define="\n- records view/records;\n- "\n+ <metal:main metal:fill-slot="prefs_configlet_main"\n+ tal:define="\n+ records view/records;\n+ "\n >\n \n <header>\n@@ -251,6 +250,6 @@\n </div>\n </div>\n </div>\n- </article>\n+ </metal:main>\n </body>\n </html>\n' | ||
b'diff --git a/news/97.bugfix b/news/97.bugfix\nnew file mode 100644\nindex 0000000..ed4ac8f\n--- /dev/null\n+++ b/news/97.bugfix\n@@ -0,0 +1,2 @@\n+Fix potential issue calculating breaches with objects sharing the same prefix\n+[pgrunewald]\n\\ No newline at end of file\ndiff --git a/plone/app/linkintegrity/browser/info.py b/plone/app/linkintegrity/browser/info.py\nindex 4f6df41..41d7e35 100644\n--- a/plone/app/linkintegrity/browser/info.py\n+++ b/plone/app/linkintegrity/browser/info.py\n@@ -64,6 +64,8 @@ def get_breaches(self, items=None):\n # list of uids that are ignored\n uids_to_ignore.update([i.UID for i in brains_to_delete])\n \n+ excluded_paths = set(path2obj.keys())\n+\n # determine breaches\n for obj_path, obj in path2obj.items():\n brains_to_delete = path2brains[obj_path]\n@@ -77,7 +79,7 @@ def get_breaches(self, items=None):\n continue\n # look into potential breach\n breach = self.check_object(\n- obj=obj_to_delete, excluded_paths=set(path2obj.keys())\n+ obj=obj_to_delete, excluded_paths=excluded_paths\n )\n if breach:\n for source in breach["sources"]:\n@@ -134,7 +136,8 @@ def check_object(self, obj, excluded_path=None, excluded_paths=None):\n continue\n if any(\n [\n- source_path.startswith(excluded_path)\n+ source_path == excluded_path\n+ or source_path.startswith(excluded_path + "/")\n for excluded_path in excluded_paths\n ]\n ):\ndiff --git a/plone/app/linkintegrity/tests/test_references.py b/plone/app/linkintegrity/tests/test_references.py\nindex 1afb921..945b6cd 100644\n--- a/plone/app/linkintegrity/tests/test_references.py\n+++ b/plone/app/linkintegrity/tests/test_references.py\n@@ -278,3 +278,40 @@ def test_sources_with_multiple_links_can_appear_multiple_times(self):\n view = self.portal.restrictedTraverse("@@delete_confirmation_info")\n # deleting the two referenced document results in two reported breaches\n self.assertEqual(len(view.get_breaches([doc1, doc2])), 2)\n+\n+ def test_if_breaches_under_excluded_paths_are_ignored(self):\n+ """Test, if breaches are ignored under certain conditions."""\n+ folder_containing_doc4 = self.portal.folder1\n+ doc4 = self.portal.folder1.doc4\n+ doc1 = self.portal.doc1\n+ set_text(doc4, \'<a href="doc1">d1</a>\')\n+ # sanity check: deleting doc1 causes one breach\n+ doc4_breaches = {r.to_object for r in getOutgoingLinks(doc4)}\n+ self.assertEqual({doc1}, doc4_breaches)\n+ view = self.portal.restrictedTraverse("@@delete_confirmation_info")\n+ self.assertEqual(len(view.get_breaches([doc1])), 1)\n+ # now check for other ways, that should do not produce any breach:\n+ # a) we delete the document that links to doc1\n+ self.assertEqual(len(view.get_breaches([doc1, doc4])), 0)\n+ # b) we delete the folder, containing the document that links to doc1\n+ self.assertEqual(len(view.get_breaches([doc1, folder_containing_doc4])), 0)\n+\n+ def test_if_same_prefix_and_breaches_work(self):\n+ """Verify that the same prefix does not lead to acciddental ignored\n+ links / breaches.\n+ """\n+ from plone.app.linkintegrity.testing import create\n+\n+ doc1 = self.portal.doc1\n+ my_page = create(self.portal, "Document", id="my-page", title="My page")\n+ my_page2 = create(\n+ self.portal,\n+ "Document",\n+ id="my-page-being-linked",\n+ title="My Page Being Linked",\n+ )\n+ # Create a link, that might be overlooked since both page\' ids start\n+ # with the same string ("my-page").\n+ set_text(doc1, \'<a href="my-page-being-linked">.</a>\')\n+ view = self.portal.restrictedTraverse("@@delete_confirmation_info")\n+ self.assertEqual(len(view.get_breaches([my_page, my_page2])), 1)\n' | ||
|