Repository: plone/plone.app.blocks (language: python)

Issue:
resolveResource break when url html content contains other ++-url's 
If the url contains html content with resource url like ++resource++protect.js the resolveResource breaks.

```
2019-07-04T10:11:34 ERROR plone.app.blocks There was an error while resolving the tile: https://example.de/libraries/university-library/university-library-neu/@@plone.app.standardtiles.html/958ba5af-12aa-4c37-a551-3df744a57788?content=%3Cp%3ELorem%20ipsum%20dolor%20sit%20amet,%20consectetuer%20adipiscing%20elit.%20Sed%20posuere%20interdum%20sem.%20Quisque%20ligula%20eros%20ullamcorper%20quis,%20lacinia%20quis%20facilisis%20sed%20sapien.%20Mauris%20varius%20diam%20vitae%20arcu.%20Sed%20arcu%20lectus%20auctor%20vitae,%20consectetuer%20et%20venenatis%20eget%20velit.%20Sed%20augue%20orci,%20lacinia%20eu%20tincidunt%20et%20eleifend%20nec%20lacus.%3C/p%3E%0A%3Cp%3EDonec%20ultricies%20nisl%20ut%20felis,%20suspendisse%20potenti.%20Lorem%20ipsum%20ligula%20ut%20hendrerit%20mollis,%20ipsum%20erat%20vehicula%20risus,%20eu%20suscipit%20sem%20libero%20nec%20erat.%20Aliquam%20erat%20volutpat.%20Sed%20congue%20augue%20vitae%20neque.%20Nulla%20consectetuer%20porttitor%20pede.%20Fusce%20purus%20morbi%20tortor%20magna%20condimentum%20vel,%20placerat%20id%20blandit%20sit%20amet%20tortor.%3C/p%3E%0A&content=%3Cp%3ELorem%20ipsum%20dolor%20sit%20amet,%20consectetuer%20adipiscing%20elit.%20Sed%20posuere%20interdum%20sem.%20Quisque%20ligula%20eros%20ullamcorper%20quis,%20lacinia%20quis%20facilisis%20sed%20sapien.%20Mauris%20varius%20diam%20vitae%20arcu.%20Sed%20arcu%20lectus%20auctor%20vitae,%20consectetuer%20et%20venenatis%20eget%20velit.%20Sed%20augue%20orci,%20lacinia%20eu%20tincidunt%20et%20eleifend%20nec%20lacus.%3C/p%3E%0A%3Cp%3EDonec%20ultricies%20nisl%20ut%20felis,%20suspendisse%20potenti.%20Lorem%20ipsum%20ligula%20ut%20hendrerit%20mollis,%20ipsum%20erat%20vehicula%20risus,%20eu%20suscipit%20sem%20libero%20nec%20erat.%20Aliquam%20erat%20volutpat.%20Sed%20congue%20augue%20vitae%20neque.%20Nulla%20consectetuer%20porttitor%20pede.%20Fusce%20purus%20morbi%20tortor%20magna%20condimentum%20vel,%20placerat%20id%20blandit%20sit%20amet%20tortor.%3C/p%3E%0A%3Cscript%20type=%22application/javascript%22%20id=%22protect-script%22%20src=%22../../../++resource++protect.js%22%20data-token=%2255742a880cb1e005b07a1b266b8396bb513c1863%22%20data-site-url=%22http://example.de%22%3E%3C/script%3E%0A&&content=%3Cp%3ELorem%20ipsum%20dolor%20sit%20amet,%20consectetuer%20adipiscing%20elit.%20Sed%20posuere%20interdum%20sem.%20Quisque%20ligula%20eros%20ullamcorper%20quis,%20lacinia%20quis%20facilisis%20sed%20sapien.%20Mauris%20varius%20diam%20vitae%20arcu.%20Sed%20arcu%20lectus%20auctor%20vitae,%20consectetuer%20et%20venenatis%20eget%20velit.%20Sed%20augue%20orci,%20lacinia%20eu%20tincidunt%20et%20eleifend%20nec%20lacus.%3C/p%3E%0A%3Cp%3EDonec%20ultricies%20nisl%20ut%20felis,%20suspendisse%20potenti.%20Lorem%20ipsum%20ligula%20ut%20hendrerit%20mollis,%20ipsum%20erat%20vehicula%20risus,%20eu%20suscipit%20sem%20libero%20nec%20erat.%20Aliquam%20erat%20volutpat.%20Sed%20congue%20augue%20vitae%20neque.%20Nulla%20consectetuer%20porttitor%20pede.%20Fusce%20purus%20morbi%20tortor%20magna%20condimentum%20vel,%20placerat%20id%20blandit%20sit%20amet%20tortor.%3C/p%3E%0A&X-Tile-Persistent=yes
Traceback (most recent call last):
  File "/usr/local/plone-5.1/example/checkout/src/plone.app.blocks/plone/app/blocks/utils.py", line 74, in resolve
    resolved = resolveResource(url)
  File "/usr/local/plone-5.1/example/checkout/src/plone.app.blocks/plone/app/blocks/utils.py", line 122, in resolveResource
    _, resource_type, path = path.split('++')
ValueError: need more than 1 value to unpack
```



Discussion / hints:

Fix patch:
diff --git a/CHANGES.rst b/CHANGES.rst
index a8dae514..1e8e1f10 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -12,6 +12,9 @@ Bug fixes:
   data was updated programmatically [fixes #75]
   [datakurre]
 
+- Fix issue where resolveResource would break when url html content param contains other ++-url's
+  [MrTango]
+
 4.3.1 (2019-02-20)
 ------------------
 
diff --git a/plone/app/blocks/utils.py b/plone/app/blocks/utils.py
index eafae97e..cb4fcce9 100644
--- a/plone/app/blocks/utils.py
+++ b/plone/app/blocks/utils.py
@@ -116,9 +116,9 @@ def resolveResource(url):
     path, it will be made relative to the Plone site root.
     """
     url = parse.unquote(url)  # subrequest does not support quoted paths
-    if url.count('++') == 2:
+    scheme, netloc, path, params, query, fragment = parse.urlparse(url)
+    if path.count('++') == 2:
         # it is a resource that can be resolved without a subrequest
-        scheme, netloc, path, params, query, fragment = parse.urlparse(url)
         _, resource_type, path = path.split('++')
         resource_name, _, path = path.partition('/')
         directory = queryResourceDirectory(resource_type, resource_name)


Test patch:
diff --git a/plone/app/blocks/tests/test_utils.py b/plone/app/blocks/tests/test_utils.py
index 2baa5f04..04c26028 100644
--- a/plone/app/blocks/tests/test_utils.py
+++ b/plone/app/blocks/tests/test_utils.py
@@ -47,3 +47,8 @@ def test_resolve_resource(self):
     def test_resolve_resource_with_query(self):
         layout = resolveResource('/++sitelayout++testlayout1/site.html?ajax_load=1')
         self.assertIn(u'Layout panel 1', layout)
+
+    def test_resolve_resource_with_html_content(self):
+        # make sure we can handle content containing other ++ urls
+        layout = resolveResource('/?content=%3Cp%3ELorem%20ipsum%20dolor%20sit%20amet,%20consectetuer%20adipiscing%20elit.%20Sed%20posuere%20interdum%20sem.%20Quisque%20ligula%20eros%20ullamcorper%20quis,%20lacinia%20quis%20facilisis%20sed%20sapien.%3C/p%3E%0A%3Cscript%20type=%22application/javascript%22%20id=%22protect-script%22%20src=%22../../../++resource++protect.js')
+        self.assertIn(u'Plone Open Source CMS', layout)