-
-
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.
Branch: refs/heads/main Date: 2024-10-30T13:54:38-07:00 Author: David Glick (davisagli) <[email protected]> Commit: plone/plone.restapi@3f72b6d Preparing release 9.8.2 Files changed: M CHANGES.rst M setup.py D news/1828.bugfix Repository: plone.restapi Branch: refs/heads/main Date: 2024-10-30T13:55:16-07:00 Author: David Glick (davisagli) <[email protected]> Commit: plone/plone.restapi@e7bd7b7 Back to development: 9.8.3 Files changed: M setup.py
- Loading branch information
Showing
1 changed file
with
24 additions
and
36 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 |
---|---|---|
|
@@ -2,43 +2,31 @@ Repository: plone.restapi | |
|
||
|
||
Branch: refs/heads/main | ||
Date: 2024-10-30T13:43:55-07:00 | ||
Author: Teodor Voicu (tedw87) <[email protected]> | ||
Commit: https://github.com/plone/plone.restapi/commit/b9ca1f9afa2d26193df8513f14cb159a2a83a012 | ||
|
||
Handle parentheses search queries (#1828) | ||
|
||
* escape parantheses in query | ||
|
||
* reformat code | ||
|
||
* add changelog | ||
|
||
* Update news/1828.bugfix | ||
|
||
Co-authored-by: Steve Piercy <[email protected]> | ||
|
||
* Update src/plone/restapi/search/handler.py | ||
|
||
Co-authored-by: Steve Piercy <[email protected]> | ||
|
||
* add tests for searching with parantheses | ||
|
||
* format code | ||
|
||
* run black to format code | ||
|
||
* Update news/1828.bugfix | ||
|
||
--------- | ||
|
||
Co-authored-by: Steve Piercy <[email protected]> | ||
Co-authored-by: David Glick <[email protected]> | ||
Date: 2024-10-30T13:54:38-07:00 | ||
Author: David Glick (davisagli) <[email protected]> | ||
Commit: https://github.com/plone/plone.restapi/commit/3f72b6d83c3a2a4ae42dd1d8a0db551a2bc49433 | ||
|
||
Preparing release 9.8.2 | ||
|
||
Files changed: | ||
M CHANGES.rst | ||
M setup.py | ||
D news/1828.bugfix | ||
|
||
b'diff --git a/CHANGES.rst b/CHANGES.rst\nindex 46e94d885..4954960da 100644\n--- a/CHANGES.rst\n+++ b/CHANGES.rst\n@@ -8,6 +8,15 @@ Changelog\n \n .. towncrier release notes start\n \n+9.8.2 (2024-10-30)\n+------------------\n+\n+Bug fixes:\n+\n+\n+- `@search` service: Remove parentheses from search query. @tedw87 (#1828)\n+\n+\n 9.8.1 (2024-10-23)\n ------------------\n \ndiff --git a/news/1828.bugfix b/news/1828.bugfix\ndeleted file mode 100644\nindex dfc2a5ef4..000000000\n--- a/news/1828.bugfix\n+++ /dev/null\n@@ -1 +0,0 @@\n-`@search` service: Remove parentheses from search query. @tedw87\n\\ No newline at end of file\ndiff --git a/setup.py b/setup.py\nindex eff315196..2f2f82819 100644\n--- a/setup.py\n+++ b/setup.py\n@@ -4,7 +4,7 @@\n import sys\n \n \n-version = "9.8.2.dev0"\n+version = "9.8.2"\n \n if sys.version_info.major == 2:\n raise ValueError(\n' | ||
|
||
Repository: plone.restapi | ||
|
||
|
||
Branch: refs/heads/main | ||
Date: 2024-10-30T13:55:16-07:00 | ||
Author: David Glick (davisagli) <[email protected]> | ||
Commit: https://github.com/plone/plone.restapi/commit/e7bd7b7ed842072f659ee34e8fcc2ced4eba5a8c | ||
|
||
Back to development: 9.8.3 | ||
|
||
Files changed: | ||
A news/1828.bugfix | ||
M src/plone/restapi/search/handler.py | ||
M src/plone/restapi/tests/test_search.py | ||
M setup.py | ||
|
||
b'diff --git a/news/1828.bugfix b/news/1828.bugfix\nnew file mode 100644\nindex 000000000..dfc2a5ef4\n--- /dev/null\n+++ b/news/1828.bugfix\n@@ -0,0 +1 @@\n+`@search` service: Remove parentheses from search query. @tedw87\n\\ No newline at end of file\ndiff --git a/src/plone/restapi/search/handler.py b/src/plone/restapi/search/handler.py\nindex 8764a773d..2a362e05d 100644\n--- a/src/plone/restapi/search/handler.py\n+++ b/src/plone/restapi/search/handler.py\n@@ -75,6 +75,10 @@ def _constrain_query_by_path(self, query):\n path = "/".join(self.context.getPhysicalPath())\n query["path"]["query"] = path\n \n+ def quote_chars(self, query):\n+ # Remove parentheses from the query\n+ return query.replace("(", " ").replace(")", " ").strip()\n+\n def search(self, query=None):\n if query is None:\n query = {}\n@@ -93,6 +97,12 @@ def search(self, query=None):\n if use_site_search_settings:\n query = self.filter_query(query)\n \n+ if "SearchableText" in query:\n+ # Sanitize SearchableText by removing parentheses\n+ query["SearchableText"] = self.quote_chars(query["SearchableText"])\n+ if not query["SearchableText"] or query["SearchableText"] == "*":\n+ return []\n+\n self._constrain_query_by_path(query)\n query = self._parse_query(query)\n \n@@ -100,7 +110,6 @@ def search(self, query=None):\n results = getMultiAdapter((lazy_resultset, self.request), ISerializeToJson)(\n fullobjects=fullobjects\n )\n-\n return results\n \n def filter_types(self, types):\ndiff --git a/src/plone/restapi/tests/test_search.py b/src/plone/restapi/tests/test_search.py\nindex e4ddb4c38..84b6e0b48 100644\n--- a/src/plone/restapi/tests/test_search.py\n+++ b/src/plone/restapi/tests/test_search.py\n@@ -151,6 +151,29 @@ def test_search_on_context_constrains_query_by_path(self):\n set(result_paths(response.json())),\n )\n \n+ def test_search_with_parentheses(self):\n+ query = {"SearchableText": "("}\n+ response = self.api_session.get("/@search", params=query)\n+ self.assertEqual(response.status_code, 200)\n+ self.assertEqual(\n+ response.json(), [], "Expected no items for query with only parentheses"\n+ )\n+\n+ query = {"SearchableText": ")"}\n+ response = self.api_session.get("/@search", params=query)\n+ self.assertEqual(response.status_code, 200)\n+ self.assertEqual(\n+ response.json(), [], "Expected no items for query with only parentheses"\n+ )\n+\n+ query = {"SearchableText": "lorem(ipsum)"}\n+ response = self.api_session.get("/@search", params=query)\n+ self.assertEqual(response.status_code, 200)\n+ items = [item["title"] for item in response.json().get("items", [])]\n+ self.assertIn(\n+ "Lorem Ipsum", items, "Expected \'Lorem Ipsum\' to be found in search results"\n+ )\n+\n def test_search_in_vhm(self):\n # Install a Virtual Host Monster\n if "virtual_hosting" not in self.app.objectIds():\n' | ||
b'diff --git a/setup.py b/setup.py\nindex 2f2f82819..183ac1eed 100644\n--- a/setup.py\n+++ b/setup.py\n@@ -4,7 +4,7 @@\n import sys\n \n \n-version = "9.8.2"\n+version = "9.8.3.dev0"\n \n if sys.version_info.major == 2:\n raise ValueError(\n' | ||
|