-
-
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:43:55-07:00 Author: Teodor Voicu (tedw87) <[email protected]> Commit: plone/plone.restapi@b9ca1f9 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]> Files changed: A news/1828.bugfix M src/plone/restapi/search/handler.py M src/plone/restapi/tests/test_search.py
- Loading branch information
Showing
1 changed file
with
37 additions
and
43 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,50 +1,44 @@ | ||
Repository: plone.volto | ||
Repository: plone.restapi | ||
|
||
|
||
Branch: refs/heads/main | ||
Date: 2024-10-30T12:53:11-07:00 | ||
Author: David Glick (davisagli) <[email protected]> | ||
Commit: https://github.com/plone/plone.volto/commit/49c82429f71347b8557d8f5022411d57b54d2f00 | ||
|
||
make it a beta release | ||
|
||
Files changed: | ||
M setup.py | ||
|
||
b'diff --git a/setup.py b/setup.py\nindex 2f486d7..9547efe 100644\n--- a/setup.py\n+++ b/setup.py\n@@ -13,7 +13,7 @@\n \n setup(\n name="plone.volto",\n- version="5.0.0a1.dev0",\n+ version="5.0.0b1.dev0",\n description="Volto integration add-on for Plone",\n long_description=long_description,\n long_description_content_type="text/markdown",\n' | ||
|
||
Repository: plone.volto | ||
|
||
|
||
Branch: refs/heads/main | ||
Date: 2024-10-30T12:53:52-07:00 | ||
Author: David Glick (davisagli) <[email protected]> | ||
Commit: https://github.com/plone/plone.volto/commit/42ae9a70b4c10841560fbe216f84213de6528fda | ||
|
||
Preparing release 5.0.0b1 | ||
|
||
Files changed: | ||
M CHANGES.md | ||
M setup.py | ||
D news/+ignore.internal | ||
D news/155.breaking.1 | ||
D news/155.breaking.2 | ||
D news/155.feature | ||
|
||
b'diff --git a/CHANGES.md b/CHANGES.md\nindex 3fb7368..97c3dd1 100644\n--- a/CHANGES.md\n+++ b/CHANGES.md\n@@ -9,6 +9,26 @@\n \n <!-- towncrier release notes start -->\n \n+## 5.0.0b1 (2024-10-30)\n+\n+\n+### Breaking changes:\n+\n+- Drop support for Plone 5.2 and Plone 6.0 [@ericof] #155\n+- The following GenericSetup profiles were removed: `default-homepage`,\n+ `default-homepage-drafjs`, `default-homepage-slate`, `demo` and `richtext`. @davisagli #155\n+\n+\n+### New features:\n+\n+- This package now contains a Plone distribution named "default". @ericof #155\n+\n+\n+### Internal:\n+\n+- setup.py: specify the encoding, otherwise it fails on Windows.\n+ [maurits] \n+\n ## 4.4.3 (2024-08-01)\n \n Bug fixes:\ndiff --git a/news/+ignore.internal b/news/+ignore.internal\ndeleted file mode 100644\nindex f6bc2ea..0000000\n--- a/news/+ignore.internal\n+++ /dev/null\n@@ -1,2 +0,0 @@\n-setup.py: specify the encoding, otherwise it fails on Windows.\n-[maurits]\ndiff --git a/news/155.breaking.1 b/news/155.breaking.1\ndeleted file mode 100644\nindex 3eddea4..0000000\n--- a/news/155.breaking.1\n+++ /dev/null\n@@ -1 +0,0 @@\n-Drop support for Plone 5.2 and Plone 6.0 [@ericof]\ndiff --git a/news/155.breaking.2 b/news/155.breaking.2\ndeleted file mode 100644\nindex 926d9db..0000000\n--- a/news/155.breaking.2\n+++ /dev/null\n@@ -1,2 +0,0 @@\n-The following GenericSetup profiles were removed: `default-homepage`,\n-`default-homepage-drafjs`, `default-homepage-slate`, `demo` and `richtext`. @davisagli\ndiff --git a/news/155.feature b/news/155.feature\ndeleted file mode 100644\nindex 901e00c..0000000\n--- a/news/155.feature\n+++ /dev/null\n@@ -1 +0,0 @@\n-This package now contains a Plone distribution named "default". @ericof\ndiff --git a/setup.py b/setup.py\nindex 9547efe..fe8ea71 100644\n--- a/setup.py\n+++ b/setup.py\n@@ -13,7 +13,7 @@\n \n setup(\n name="plone.volto",\n- version="5.0.0b1.dev0",\n+ version="5.0.0b1",\n description="Volto integration add-on for Plone",\n long_description=long_description,\n long_description_content_type="text/markdown",\n' | ||
|
||
Repository: plone.volto | ||
|
||
|
||
Branch: refs/heads/main | ||
Date: 2024-10-30T12:54:32-07:00 | ||
Author: David Glick (davisagli) <[email protected]> | ||
Commit: https://github.com/plone/plone.volto/commit/482e21b78a55e438c7dc8b0ff50fcb129bb49e6b | ||
|
||
Back to development: 5.0.0b2 | ||
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]> | ||
|
||
Files changed: | ||
M setup.py | ||
A news/1828.bugfix | ||
M src/plone/restapi/search/handler.py | ||
M src/plone/restapi/tests/test_search.py | ||
|
||
b'diff --git a/setup.py b/setup.py\nindex fe8ea71..5c51a53 100644\n--- a/setup.py\n+++ b/setup.py\n@@ -13,7 +13,7 @@\n \n setup(\n name="plone.volto",\n- version="5.0.0b1",\n+ version="5.0.0b2.dev0",\n description="Volto integration add-on for Plone",\n long_description=long_description,\n long_description_content_type="text/markdown",\n' | ||
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' | ||
|