diff --git a/last_commit.txt b/last_commit.txt index 1f51a78ad8..ed1aef72e7 100644 --- a/last_commit.txt +++ b/last_commit.txt @@ -1,51 +1,34 @@ -Repository: plone.app.querystring +Repository: Products.CMFPlone Branch: refs/heads/master -Date: 2023-11-29T13:33:12+01:00 -Author: Mikel Larreategi (erral) -Commit: https://github.com/plone/plone.app.querystring/commit/c66c920642887141ec6c9ac2fcf87f363d12de01 +Date: 2023-12-11T16:01:24+01:00 +Author: Jens W. Klein (jensens) +Commit: https://github.com/plone/Products.CMFPlone/commit/7e50e843fb13097ddcf55bfc4d0220e9955c658e -handle parenthesis inside quotes +mark get_production_resource_directory deprectated Files changed: -A news/139.bugfix -M plone/app/querystring/querybuilder.py -M plone/app/querystring/tests/testQueryBuilder.py +A news/3887.bugfix +M Products/CMFPlone/resources/utils.py -b'diff --git a/news/139.bugfix b/news/139.bugfix\nnew file mode 100644\nindex 0000000..ec4772e\n--- /dev/null\n+++ b/news/139.bugfix\n@@ -0,0 +1,2 @@\n+Handle parenthesis inside quotes\n+[erral]\ndiff --git a/plone/app/querystring/querybuilder.py b/plone/app/querystring/querybuilder.py\nindex d9ef15b..bd8978f 100644\n--- a/plone/app/querystring/querybuilder.py\n+++ b/plone/app/querystring/querybuilder.py\n@@ -44,10 +44,11 @@ def _quote(term):\n # being parsed as logical query atoms.\n if term.lower() in ("and", "or", "not"):\n term = \'"%s"\' % term\n- return term\n+ return _quote_chars(term)\n \n \n def munge_search_term(query):\n+ original_query = query\n for char in _BAD_CHARS:\n query = query.replace(char, " ")\n \n@@ -66,7 +67,7 @@ def munge_search_term(query):\n \n r += map(_quote, query.strip().split())\n r = " AND ".join(r)\n- r = _quote_chars(r) + ("*" if r and not r.endswith(\'"\') else "")\n+ r = r + ("*" if r and not original_query.endswith(\'"\') else "")\n return r\n \n \ndiff --git a/plone/app/querystring/tests/testQueryBuilder.py b/plone/app/querystring/tests/testQueryBuilder.py\nindex 4c39838..48b6e43 100644\n--- a/plone/app/querystring/tests/testQueryBuilder.py\n+++ b/plone/app/querystring/tests/testQueryBuilder.py\n@@ -326,6 +326,80 @@ def testQueryBuilderCustomQueryDoNotOverrideValues(self):\n self.assertEqual(results[0].Title(), "Collectionstestpage 2")\n \n \n+ def test_munge_search_term(self):\n+ from plone.app.querystring.querybuilder import _BAD_CHARS\n+ from plone.app.querystring.querybuilder import munge_search_term\n+\n+ search_term_tests = [\n+ (\n+ # search term\n+ "spam ham",\n+ "spam AND ham*",\n+ ),\n+ (\n+ # quoted term\n+ \'"spam ham"\',\n+ \'"spam ham"\',\n+ ),\n+ (\n+ # cleanup quoted terms\n+ \'" spam ham "\',\n+ \'"spam ham"\',\n+ ),\n+ (\n+ # quoted term with inner parenthesis\n+ \'"spam (ham)"\',\n+ \'"spam (ham)"\',\n+ ),\n+ (\n+ # quoted term with inner parenthesis\n+ \'"spam" (ham)\',\n+ \'"spam" AND "("ham")"*\',\n+ ),\n+ (\n+ # quoted term with inner parenthesis\n+ \'"(spam ham)"\',\n+ \'"(spam ham)"\',\n+ ),\n+ (\n+ # mixed cases\n+ "Spam hAm",\n+ "Spam AND hAm*",\n+ ),\n+ (\n+ # mix quoting and unquoted\n+ \'let\\\'s eat some "ham and eggs " without spam \',\n+ \'"ham and eggs" AND let\\\'s AND eat AND some \' "AND without AND spam*",\n+ ),\n+ (\n+ \'test "Welcome" to "Plone" retest\',\n+ \'"Welcome" AND "Plone" AND test AND to AND retest*\',\n+ ),\n+ (\n+ # parentheses\n+ "spam (ham)",\n+ \'spam AND "("ham")"*\',\n+ ),\n+ (\n+ # special keywords\n+ "spam or not ham and eggs",\n+ \'spam AND "or" AND "not" AND ham AND "and" AND eggs*\',\n+ ),\n+ (\n+ # bad characters\n+ " ".join(_BAD_CHARS),\n+ "",\n+ ),\n+ (\n+ # weird input\n+ \'test ""Welcome" to "Plone"" retest\',\n+ \'"to" AND test AND WelcomePlone AND retest*\',\n+ ),\n+ ]\n+\n+ for _in, _out in search_term_tests:\n+ self.assertEqual(munge_search_term(_in), _out)\n+\n class TestQuerybuilderResultTypes(unittest.TestCase):\n layer = TEST_PROFILE_PLONEAPPQUERYSTRING_INTEGRATION_TESTING\n \n' +b'diff --git a/Products/CMFPlone/resources/utils.py b/Products/CMFPlone/resources/utils.py\nindex e72f9553fe..a0632ec8dc 100644\n--- a/Products/CMFPlone/resources/utils.py\n+++ b/Products/CMFPlone/resources/utils.py\n@@ -8,6 +8,7 @@\n from Products.CMFCore.utils import getToolByName\n from zExceptions import NotFound\n from zope.component import queryUtility\n+from zope.deprecation import deprecate\n \n import logging\n \n@@ -16,7 +17,12 @@\n logger = logging.getLogger(__name__)\n \n \n+@deprecate(\n+ "get_production_resource_directory is deprecated and will be removed in Plone 7. "\n+)\n def get_production_resource_directory():\n+ # this function is not used in Plone 6.1 anymore, but we keep it for\n+ # backwards compatibility until Plone 7\n persistent_directory = queryUtility(IResourceDirectory, name="persistent")\n if persistent_directory is None:\n return ""\ndiff --git a/news/3887.bugfix b/news/3887.bugfix\nnew file mode 100644\nindex 0000000000..3cfbd5fff6\n--- /dev/null\n+++ b/news/3887.bugfix\n@@ -0,0 +1,2 @@\n+Deprecate `get_production_resource_directory` since it is not used anywhere in core.\n+[@jensens]\n\\ No newline at end of file\n' -Repository: plone.app.querystring +Repository: Products.CMFPlone Branch: refs/heads/master -Date: 2023-11-29T13:35:51+01:00 -Author: Mikel Larreategi (erral) -Commit: https://github.com/plone/plone.app.querystring/commit/5b2909f448b6da18ddb5751acc6e2dffef4cbedd +Date: 2023-12-14T12:25:33+01:00 +Author: Maurits van Rees (mauritsvanrees) +Commit: https://github.com/plone/Products.CMFPlone/commit/5f8f65a89b787c33a90c05eee80eeb86e31d56a2 -run black +Merge pull request #3887 from plone/deprecate-get_production_resource_directory -Files changed: -M plone/app/querystring/tests/testQueryBuilder.py - -b'diff --git a/plone/app/querystring/tests/testQueryBuilder.py b/plone/app/querystring/tests/testQueryBuilder.py\nindex 48b6e43..6a79bf0 100644\n--- a/plone/app/querystring/tests/testQueryBuilder.py\n+++ b/plone/app/querystring/tests/testQueryBuilder.py\n@@ -325,7 +325,6 @@ def testQueryBuilderCustomQueryDoNotOverrideValues(self):\n self.assertEqual(len(results), 1)\n self.assertEqual(results[0].Title(), "Collectionstestpage 2")\n \n-\n def test_munge_search_term(self):\n from plone.app.querystring.querybuilder import _BAD_CHARS\n from plone.app.querystring.querybuilder import munge_search_term\n@@ -400,6 +399,7 @@ def test_munge_search_term(self):\n for _in, _out in search_term_tests:\n self.assertEqual(munge_search_term(_in), _out)\n \n+\n class TestQuerybuilderResultTypes(unittest.TestCase):\n layer = TEST_PROFILE_PLONEAPPQUERYSTRING_INTEGRATION_TESTING\n \n' - -Repository: plone.app.querystring - - -Branch: refs/heads/master -Date: 2023-12-14T12:20:43+01:00 -Author: Maurits van Rees (mauritsvanrees) -Commit: https://github.com/plone/plone.app.querystring/commit/84d730b65b1260c7eec85efcc3ab23116c150a2e - -Merge pull request #140 from plone/erral-issue-139 - -handle parenthesis inside quotes +mark get_production_resource_directory deprectated Files changed: -A news/139.bugfix -M plone/app/querystring/querybuilder.py -M plone/app/querystring/tests/testQueryBuilder.py +A news/3887.bugfix +M Products/CMFPlone/resources/utils.py -b'diff --git a/news/139.bugfix b/news/139.bugfix\nnew file mode 100644\nindex 0000000..ec4772e\n--- /dev/null\n+++ b/news/139.bugfix\n@@ -0,0 +1,2 @@\n+Handle parenthesis inside quotes\n+[erral]\ndiff --git a/plone/app/querystring/querybuilder.py b/plone/app/querystring/querybuilder.py\nindex d9ef15b..bd8978f 100644\n--- a/plone/app/querystring/querybuilder.py\n+++ b/plone/app/querystring/querybuilder.py\n@@ -44,10 +44,11 @@ def _quote(term):\n # being parsed as logical query atoms.\n if term.lower() in ("and", "or", "not"):\n term = \'"%s"\' % term\n- return term\n+ return _quote_chars(term)\n \n \n def munge_search_term(query):\n+ original_query = query\n for char in _BAD_CHARS:\n query = query.replace(char, " ")\n \n@@ -66,7 +67,7 @@ def munge_search_term(query):\n \n r += map(_quote, query.strip().split())\n r = " AND ".join(r)\n- r = _quote_chars(r) + ("*" if r and not r.endswith(\'"\') else "")\n+ r = r + ("*" if r and not original_query.endswith(\'"\') else "")\n return r\n \n \ndiff --git a/plone/app/querystring/tests/testQueryBuilder.py b/plone/app/querystring/tests/testQueryBuilder.py\nindex 4c39838..6a79bf0 100644\n--- a/plone/app/querystring/tests/testQueryBuilder.py\n+++ b/plone/app/querystring/tests/testQueryBuilder.py\n@@ -325,6 +325,80 @@ def testQueryBuilderCustomQueryDoNotOverrideValues(self):\n self.assertEqual(len(results), 1)\n self.assertEqual(results[0].Title(), "Collectionstestpage 2")\n \n+ def test_munge_search_term(self):\n+ from plone.app.querystring.querybuilder import _BAD_CHARS\n+ from plone.app.querystring.querybuilder import munge_search_term\n+\n+ search_term_tests = [\n+ (\n+ # search term\n+ "spam ham",\n+ "spam AND ham*",\n+ ),\n+ (\n+ # quoted term\n+ \'"spam ham"\',\n+ \'"spam ham"\',\n+ ),\n+ (\n+ # cleanup quoted terms\n+ \'" spam ham "\',\n+ \'"spam ham"\',\n+ ),\n+ (\n+ # quoted term with inner parenthesis\n+ \'"spam (ham)"\',\n+ \'"spam (ham)"\',\n+ ),\n+ (\n+ # quoted term with inner parenthesis\n+ \'"spam" (ham)\',\n+ \'"spam" AND "("ham")"*\',\n+ ),\n+ (\n+ # quoted term with inner parenthesis\n+ \'"(spam ham)"\',\n+ \'"(spam ham)"\',\n+ ),\n+ (\n+ # mixed cases\n+ "Spam hAm",\n+ "Spam AND hAm*",\n+ ),\n+ (\n+ # mix quoting and unquoted\n+ \'let\\\'s eat some "ham and eggs " without spam \',\n+ \'"ham and eggs" AND let\\\'s AND eat AND some \' "AND without AND spam*",\n+ ),\n+ (\n+ \'test "Welcome" to "Plone" retest\',\n+ \'"Welcome" AND "Plone" AND test AND to AND retest*\',\n+ ),\n+ (\n+ # parentheses\n+ "spam (ham)",\n+ \'spam AND "("ham")"*\',\n+ ),\n+ (\n+ # special keywords\n+ "spam or not ham and eggs",\n+ \'spam AND "or" AND "not" AND ham AND "and" AND eggs*\',\n+ ),\n+ (\n+ # bad characters\n+ " ".join(_BAD_CHARS),\n+ "",\n+ ),\n+ (\n+ # weird input\n+ \'test ""Welcome" to "Plone"" retest\',\n+ \'"to" AND test AND WelcomePlone AND retest*\',\n+ ),\n+ ]\n+\n+ for _in, _out in search_term_tests:\n+ self.assertEqual(munge_search_term(_in), _out)\n+\n \n class TestQuerybuilderResultTypes(unittest.TestCase):\n layer = TEST_PROFILE_PLONEAPPQUERYSTRING_INTEGRATION_TESTING\n' +b'diff --git a/Products/CMFPlone/resources/utils.py b/Products/CMFPlone/resources/utils.py\nindex e72f9553fe..a0632ec8dc 100644\n--- a/Products/CMFPlone/resources/utils.py\n+++ b/Products/CMFPlone/resources/utils.py\n@@ -8,6 +8,7 @@\n from Products.CMFCore.utils import getToolByName\n from zExceptions import NotFound\n from zope.component import queryUtility\n+from zope.deprecation import deprecate\n \n import logging\n \n@@ -16,7 +17,12 @@\n logger = logging.getLogger(__name__)\n \n \n+@deprecate(\n+ "get_production_resource_directory is deprecated and will be removed in Plone 7. "\n+)\n def get_production_resource_directory():\n+ # this function is not used in Plone 6.1 anymore, but we keep it for\n+ # backwards compatibility until Plone 7\n persistent_directory = queryUtility(IResourceDirectory, name="persistent")\n if persistent_directory is None:\n return ""\ndiff --git a/news/3887.bugfix b/news/3887.bugfix\nnew file mode 100644\nindex 0000000000..3cfbd5fff6\n--- /dev/null\n+++ b/news/3887.bugfix\n@@ -0,0 +1,2 @@\n+Deprecate `get_production_resource_directory` since it is not used anywhere in core.\n+[@jensens]\n\\ No newline at end of file\n'