collective / collective/collective.oembed
collective.oembed fails to URL decode paths
- Dominant language
- Python
- Stars
- 6
- Forks
- 6
- PR merge metrics
- No merged PRs in 30d
Description
The following page throws an exception using Plone 4.3.4 with collective.oembed 2.0.1 :
http://www.ucs.cam.ac.uk/@@oembed?url=http%3A%2F%2Fwww.ucs.cam.ac.uk%2Fsupport%2Fmcs-support%2Fmcsadmin%2Fmcsforum%2FMCS%2520Forum%2520Dec%25202014&format=xml
The full error is:
```
2015-04-08T11:29:00 ERROR Zope.SiteErrorLog 1428488940.780.292110604726 http://www.ucs.cam.ac.uk/@@oembed
Traceback (innermost last):
Module ZPublisher.Publish, line 138, in publish
Module ZPublisher.mapply, line 77, in mapply
Module ZPublisher.Publish, line 48, in call_object
Module collective.oembed.provider, line 33, in __call__
Module collective.oembed.provider, line 44, in update
Module collective.oembed.provider, line 73, in updateBuild
Module collective.oembed.provider, line 135, in get_target
Module OFS.Traversable, line 317, in restrictedTraverse
Module OFS.Traversable, line 285, in unrestrictedTraverse
traceback_info__: ([], 'MCS%20Forum%20Dec%202014')
AttributeError: MCS%20Forum%20Dec%202014
```
The problem would seem to be that collective oembed is failing to URL decode the %20 encoded spaces in the path.
```
collective.oembed.provider.py :
class OEmbedProvider(BrowserView):
...
def get_target(self):
....
if self._target is None:
try:
# remove heading /
self._target = site.restrictedTraverse(path[1:])
```
Here's the output from a PDB session attached to that code:
```
(Pdb) p site.restrictedTraverse('support/mcs-support/mcsadmin/mcsforum/MCS%20Forum%20Dec%202014')
*** AttributeError: AttributeError('MCS%20Forum%20Dec%202014',)
(Pdb) p site.restrictedTraverse('support/mcs-support/mcsadmin/mcsforum/MCS Forum Dec 2014')
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Start in collective.oembed.provider.py at OEmbedProvider.get_target and reproduce the supplied @@oembed URL. Check how the path is passed to site.restrictedTraverse and verify that the encoded spaces resolve to the shown ATFile without raising AttributeError; done means the endpoint handles this URL successfully.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100