Skip to content

Commit

Permalink
[fc] Repository: plone.rest
Browse files Browse the repository at this point in the history
Branch: refs/heads/main
Date: 2023-10-26T11:26:16-07:00
Author: Dylan Jay (djay) <[email protected]>
Commit: plone/plone.rest@ca5bee8

fix for weird requests with media types with extra /

Files changed:
M src/plone/rest/negotiation.py
Repository: plone.rest

Branch: refs/heads/main
Date: 2023-10-26T11:26:16-07:00
Author: David Glick (davisagli) <[email protected]>
Commit: plone/plone.rest@c7115e6

add test

Files changed:
M src/plone/rest/tests/test_negotiation.py
Repository: plone.rest

Branch: refs/heads/main
Date: 2023-10-26T11:26:16-07:00
Author: David Glick (davisagli) <[email protected]>
Commit: plone/plone.rest@dc7eccf

black

Files changed:
M src/plone/rest/tests/test_negotiation.py
Repository: plone.rest

Branch: refs/heads/main
Date: 2023-10-26T11:26:16-07:00
Author: David Glick (davisagli) <[email protected]>
Commit: plone/plone.rest@7daa917

changelog

Files changed:
A news/153.bugfix
Repository: plone.rest

Branch: refs/heads/main
Date: 2023-10-26T13:25:38-07:00
Author: David Glick (davisagli) <[email protected]>
Commit: plone/plone.rest@9eca0d2

Merge pull request #153 from plone/fix_bad_media_type

fix for weird requests with media types with extra /

Files changed:
A news/153.bugfix
M src/plone/rest/negotiation.py
M src/plone/rest/tests/test_negotiation.py
  • Loading branch information
davisagli committed Oct 26, 2023
1 parent c765334 commit 7592463
Showing 1 changed file with 63 additions and 20 deletions.
83 changes: 63 additions & 20 deletions last_commit.txt
Original file line number Diff line number Diff line change
@@ -1,36 +1,79 @@
Repository: Products.CMFPlone
Repository: plone.rest


Branch: refs/heads/6.0.x
Date: 2023-10-25T14:04:17+02:00
Author: Johannes Raggam (thet) <thetetet@gmail.com>
Commit: https://github.com/plone/Products.CMFPlone/commit/98dc3661009679dcca01618c3b8d6b618946db5b
Branch: refs/heads/main
Date: 2023-10-26T11:26:16-07:00
Author: Dylan Jay (djay) <software@pretaweb.com>
Commit: https://github.com/plone/plone.rest/commit/ca5bee89636cf3e5da350500cadec19b383fd01c

Fix problem when adding a Plone site with a custom INonInstallable utility without a getNonInstallableProfiles method.
fix for weird requests with media types with extra /

Fixes: #3862.
Files changed:
M src/plone/rest/negotiation.py

b'diff --git a/src/plone/rest/negotiation.py b/src/plone/rest/negotiation.py\nindex 63f2f31..3b23eb4 100644\n--- a/src/plone/rest/negotiation.py\n+++ b/src/plone/rest/negotiation.py\n@@ -11,7 +11,7 @@ def parse_accept_header(accept):\n for media_range in accept.split(","):\n media_type = media_range.split(";")[0].strip()\n if "/" in media_type:\n- type_, subtype = media_type.split("/")\n+ type_, subtype = media_type.split("/", 1)\n media_types.append((type_, subtype))\n return media_types\n \n'

Repository: plone.rest


Branch: refs/heads/main
Date: 2023-10-26T11:26:16-07:00
Author: David Glick (davisagli) <[email protected]>
Commit: https://github.com/plone/plone.rest/commit/c7115e6451a286a3b60abd6464cdcc27d2241def

add test

Files changed:
M src/plone/rest/tests/test_negotiation.py

b'diff --git a/src/plone/rest/tests/test_negotiation.py b/src/plone/rest/tests/test_negotiation.py\nindex 3978b88..75385a3 100644\n--- a/src/plone/rest/tests/test_negotiation.py\n+++ b/src/plone/rest/tests/test_negotiation.py\n@@ -56,6 +56,9 @@ def test_parse_all_media_types_accept_header(self):\n def test_parse_invalid_accept_header(self):\n self.assertEqual([], parse_accept_header("invalid"))\n \n+ def test_parse_mimetype_with_extra_slash(self):\n+ self.assertEqual([("application", "x/y")], parse_accept_header("application/x/y"))\n+\n \n class TestServiceRegistry(unittest.TestCase):\n def test_register_media_type(self):\n'

Repository: plone.rest


Branch: refs/heads/main
Date: 2023-10-26T11:26:16-07:00
Author: David Glick (davisagli) <[email protected]>
Commit: https://github.com/plone/plone.rest/commit/dc7eccf5c5be11fc8c1b0eb91ca5a20c1c98fe90

black

Files changed:
M src/plone/rest/tests/test_negotiation.py

b'diff --git a/src/plone/rest/tests/test_negotiation.py b/src/plone/rest/tests/test_negotiation.py\nindex 75385a3..22502db 100644\n--- a/src/plone/rest/tests/test_negotiation.py\n+++ b/src/plone/rest/tests/test_negotiation.py\n@@ -57,7 +57,9 @@ def test_parse_invalid_accept_header(self):\n self.assertEqual([], parse_accept_header("invalid"))\n \n def test_parse_mimetype_with_extra_slash(self):\n- self.assertEqual([("application", "x/y")], parse_accept_header("application/x/y"))\n+ self.assertEqual(\n+ [("application", "x/y")], parse_accept_header("application/x/y")\n+ )\n \n \n class TestServiceRegistry(unittest.TestCase):\n'

Repository: plone.rest


Branch: refs/heads/main
Date: 2023-10-26T11:26:16-07:00
Author: David Glick (davisagli) <[email protected]>
Commit: https://github.com/plone/plone.rest/commit/7daa91762767e8e5d3e969339450e72a3440a440

changelog

Files changed:
A news/3862.bugfix
M Products/CMFPlone/browser/admin.py
A news/153.bugfix

b'diff --git a/Products/CMFPlone/browser/admin.py b/Products/CMFPlone/browser/admin.py\nindex 679c160383..44714defb8 100644\n--- a/Products/CMFPlone/browser/admin.py\n+++ b/Products/CMFPlone/browser/admin.py\n@@ -176,7 +176,11 @@ def profiles(self):\n ]\n utils = getAllUtilitiesRegisteredFor(INonInstallable)\n for util in utils:\n- not_installable.extend(util.getNonInstallableProfiles())\n+ not_installable.extend(\n+ util.getNonInstallableProfiles()\n+ if hasattr(util, "getNonInstallableProfiles")\n+ else []\n+ )\n \n for info in profile_registry.listProfileInfo():\n if info.get("type") == EXTENSION and info.get("for") in (\ndiff --git a/news/3862.bugfix b/news/3862.bugfix\nnew file mode 100644\nindex 0000000000..a9e0e6be6d\n--- /dev/null\n+++ b/news/3862.bugfix\n@@ -0,0 +1,3 @@\n+Fix problem when adding a Plone site with a custom INonInstallable utility without a getNonInstallableProfiles method.\n+\n+Fixes: #3862.\n'
b'diff --git a/news/153.bugfix b/news/153.bugfix\nnew file mode 100644\nindex 0000000..152666d\n--- /dev/null\n+++ b/news/153.bugfix\n@@ -0,0 +1 @@\n+Fix parsing mimetypes in Accept header with an extra slash. @djay\n'

Repository: Products.CMFPlone
Repository: plone.rest


Branch: refs/heads/6.0.x
Date: 2023-10-25T17:04:36+02:00
Author: Maurits van Rees (mauritsvanrees) <[email protected]>
Commit: https://github.com/plone/Products.CMFPlone/commit/98e53c405b2f2a916594b0db15b17c36a71d6ee8
Branch: refs/heads/main
Date: 2023-10-26T13:25:38-07:00
Author: David Glick (davisagli) <[email protected]>
Commit: https://github.com/plone/plone.rest/commit/9eca0d2d67e785763bd70496ce9d5d3e05a9ce3d

Merge pull request #3868 from plone/fix-addsite-no-getnoninstallableprofiles-60
Merge pull request #153 from plone/fix_bad_media_type

Fix problem when adding a Plone site with a custom INonInstallable ut…
fix for weird requests with media types with extra /

Files changed:
A news/3862.bugfix
M Products/CMFPlone/browser/admin.py
A news/153.bugfix
M src/plone/rest/negotiation.py
M src/plone/rest/tests/test_negotiation.py

b'diff --git a/Products/CMFPlone/browser/admin.py b/Products/CMFPlone/browser/admin.py\nindex 679c160383..44714defb8 100644\n--- a/Products/CMFPlone/browser/admin.py\n+++ b/Products/CMFPlone/browser/admin.py\n@@ -176,7 +176,11 @@ def profiles(self):\n ]\n utils = getAllUtilitiesRegisteredFor(INonInstallable)\n for util in utils:\n- not_installable.extend(util.getNonInstallableProfiles())\n+ not_installable.extend(\n+ util.getNonInstallableProfiles()\n+ if hasattr(util, "getNonInstallableProfiles")\n+ else []\n+ )\n \n for info in profile_registry.listProfileInfo():\n if info.get("type") == EXTENSION and info.get("for") in (\ndiff --git a/news/3862.bugfix b/news/3862.bugfix\nnew file mode 100644\nindex 0000000000..a9e0e6be6d\n--- /dev/null\n+++ b/news/3862.bugfix\n@@ -0,0 +1,3 @@\n+Fix problem when adding a Plone site with a custom INonInstallable utility without a getNonInstallableProfiles method.\n+\n+Fixes: #3862.\n'
b'diff --git a/news/153.bugfix b/news/153.bugfix\nnew file mode 100644\nindex 0000000..152666d\n--- /dev/null\n+++ b/news/153.bugfix\n@@ -0,0 +1 @@\n+Fix parsing mimetypes in Accept header with an extra slash. @djay\ndiff --git a/src/plone/rest/negotiation.py b/src/plone/rest/negotiation.py\nindex 63f2f31..3b23eb4 100644\n--- a/src/plone/rest/negotiation.py\n+++ b/src/plone/rest/negotiation.py\n@@ -11,7 +11,7 @@ def parse_accept_header(accept):\n for media_range in accept.split(","):\n media_type = media_range.split(";")[0].strip()\n if "/" in media_type:\n- type_, subtype = media_type.split("/")\n+ type_, subtype = media_type.split("/", 1)\n media_types.append((type_, subtype))\n return media_types\n \ndiff --git a/src/plone/rest/tests/test_negotiation.py b/src/plone/rest/tests/test_negotiation.py\nindex 3978b88..22502db 100644\n--- a/src/plone/rest/tests/test_negotiation.py\n+++ b/src/plone/rest/tests/test_negotiation.py\n@@ -56,6 +56,11 @@ def test_parse_all_media_types_accept_header(self):\n def test_parse_invalid_accept_header(self):\n self.assertEqual([], parse_accept_header("invalid"))\n \n+ def test_parse_mimetype_with_extra_slash(self):\n+ self.assertEqual(\n+ [("application", "x/y")], parse_accept_header("application/x/y")\n+ )\n+\n \n class TestServiceRegistry(unittest.TestCase):\n def test_register_media_type(self):\n'

0 comments on commit 7592463

Please sign in to comment.