Merge lp:~osomon/moovida/fix_uri_quoting into lp:moovida

Proposed by Olivier Tilloy
Status: Merged
Merged at revision: not available
Proposed branch: lp:~osomon/moovida/fix_uri_quoting
Merge into: lp:moovida
Diff against target: 131 lines (+83/-8)
3 files modified
elisa-plugins/elisa/plugins/gstreamer/decodebin2_pipeline.py (+24/-2)
elisa-plugins/elisa/plugins/gstreamer/old_pipeline.py (+24/-2)
elisa-plugins/elisa/plugins/poblesec/player_video.py (+35/-4)
To merge this branch: bzr merge lp:~osomon/moovida/fix_uri_quoting
Reviewer Review Type Date Requested Status
Guillaume Emont code functional Approve
Review via email: mp+17013@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Olivier Tilloy (osomon) wrote :

This patch fixes the symptoms of bug #491874.
It is a refinement of Fernando's patch (see http://bazaar.launchpad.net/~moovida-developers/moovida/relook/revision/1599): only "file://" URLs are escaped. URLs for distant resources thus remain unchanged.

As extensively explained in the comments I added to the code, this patch is by no means a proper fix to the underlying issue, which is that "file://" URIs are not correctly built in the first place. It is merely a quick fix, as unintrusive as possible.

The careful reviewer will make sure that the changes are relevant and that the comments make sense. He will also verify that bug #491874 is fixed in a variety of situations [1], and that indexing, thumbnailing and playback of local audio and video files containing reserved characters work fine. In particular, there shouldn't be regressions on bug #374305 and bug #296517. As noted by Fernando in the first patch, indexing and thumbnailing of pictures containing reserved characters should also work, but displaying them in the slideshow player will fail. This can be considered as a separate issue.

Thanks for all the shoes!

Olivier

[1] Tests can be done using the arte plugin using e.g. a French proxy or the grooveshark plugin. Note that for the latter, another issue prevents playback, but a patched egg is attached to bug #451125.

Revision history for this message
Guillaume Emont (guijemont) wrote :

worksforme(tm), and I'm ok with the changes.
Did test on ubuntu hardy and vista. I didn't test with chinese characters, but considering the changes, if there is no regression with the # character, there shouldn't be any regression with chinese characters either.
I guess the comment could be shorter (ideally), but I have nothing better to propose, so I'm OK with that.

review: Approve (code functional)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'elisa-plugins/elisa/plugins/gstreamer/decodebin2_pipeline.py'
--- elisa-plugins/elisa/plugins/gstreamer/decodebin2_pipeline.py 2009-11-13 18:24:48 +0000
+++ elisa-plugins/elisa/plugins/gstreamer/decodebin2_pipeline.py 2010-01-08 12:24:30 +0000
@@ -675,8 +675,30 @@
675 self.debug('unknown pad %s, caps %s' % (pad, caps))675 self.debug('unknown pad %s, caps %s' % (pad, caps))
676676
677 def _plug_src(self, uri):677 def _plug_src(self, uri):
678 quoted_uri = quote(uri, '/:')678 """
679 src = gst.element_make_from_uri(gst.URI_SRC, quoted_uri)679 @type uri: C{str}
680 """
681 if uri.startswith('file://'):
682 # Hack to workaround the messy handling of file paths using MediaUri
683 # objects. In various places in the code, file paths are not
684 # URL-escaped when building a MediaUri. It results in invalid URLs
685 # if the file path contains reserved characters
686 # (see http://tools.ietf.org/html/rfc3986#section-2.2).
687 # See https://bugs.launchpad.net/moovida/+bug/374305 and
688 # https://bugs.launchpad.net/moovida/+bug/296517 for displays of
689 # this issue.
690 # Note that while we use MediaUri objects, the clean way to fix this
691 # mess is to make sure that file paths are correctly URL-escaped and
692 # unescaped where needed (but that would be a tedious, invasive and
693 # risky patch).
694 quoted_uri = quote(uri, ':/')
695 src = gst.element_make_from_uri(gst.URI_SRC, quoted_uri)
696 else:
697 # We quote only file:// URLs. Other MediaUri objects for distant
698 # resources are assumed to be built correctly
699 # (i.e. already URL-escaped).
700 src = gst.element_make_from_uri(gst.URI_SRC, uri)
701
680 # FIXME: workaround for jpegdec that does a gst_buffer_join for each702 # FIXME: workaround for jpegdec that does a gst_buffer_join for each
681 # gst_pad_chain.703 # gst_pad_chain.
682 src.props.blocksize = 1 * 1024 * 1024704 src.props.blocksize = 1 * 1024 * 1024
683705
=== modified file 'elisa-plugins/elisa/plugins/gstreamer/old_pipeline.py'
--- elisa-plugins/elisa/plugins/gstreamer/old_pipeline.py 2009-11-13 18:24:48 +0000
+++ elisa-plugins/elisa/plugins/gstreamer/old_pipeline.py 2010-01-08 12:24:30 +0000
@@ -541,8 +541,30 @@
541 self.debug('unknown pad %s, caps %s' % (pad, caps))541 self.debug('unknown pad %s, caps %s' % (pad, caps))
542542
543 def _plug_src(self, uri):543 def _plug_src(self, uri):
544 quoted_uri = quote(uri, '/:')544 """
545 src = gst.element_make_from_uri(gst.URI_SRC, quoted_uri)545 @type uri: C{str}
546 """
547 if uri.startswith('file://'):
548 # Hack to workaround the messy handling of file paths using MediaUri
549 # objects. In various places in the code, file paths are not
550 # URL-escaped when building a MediaUri. It results in invalid URLs
551 # if the file path contains reserved characters
552 # (see http://tools.ietf.org/html/rfc3986#section-2.2).
553 # See https://bugs.launchpad.net/moovida/+bug/374305 and
554 # https://bugs.launchpad.net/moovida/+bug/296517 for displays of
555 # this issue.
556 # Note that while we use MediaUri objects, the clean way to fix this
557 # mess is to make sure that file paths are correctly URL-escaped and
558 # unescaped where needed (but that would be a tedious, invasive and
559 # risky patch).
560 quoted_uri = quote(uri, ':/')
561 src = gst.element_make_from_uri(gst.URI_SRC, quoted_uri)
562 else:
563 # We quote only file:// URLs. Other MediaUri objects for distant
564 # resources are assumed to be built correctly
565 # (i.e. already URL-escaped).
566 src = gst.element_make_from_uri(gst.URI_SRC, uri)
567
546 # FIXME: workaround for jpegdec that does a gst_buffer_join for each568 # FIXME: workaround for jpegdec that does a gst_buffer_join for each
547 # gst_pad_chain.569 # gst_pad_chain.
548 src.props.blocksize = 1 * 1024 * 1024570 src.props.blocksize = 1 * 1024 * 1024
549571
=== modified file 'elisa-plugins/elisa/plugins/poblesec/player_video.py'
--- elisa-plugins/elisa/plugins/poblesec/player_video.py 2009-12-01 12:16:26 +0000
+++ elisa-plugins/elisa/plugins/poblesec/player_video.py 2010-01-08 12:24:30 +0000
@@ -695,9 +695,22 @@
695 unicode_uri = unicode(file_uri)695 unicode_uri = unicode(file_uri)
696 sub_uri = \696 sub_uri = \
697 unicode_uri.encode(locale_helper.gst_file_encoding())697 unicode_uri.encode(locale_helper.gst_file_encoding())
698 quoted_sub_uri = quote(sub_uri, '/:')698 # Hack to workaround the messy handling of file paths using
699 # MediaUri objects. In various places in the code, file
700 # paths are not URL-escaped when building a MediaUri. It
701 # results in invalid URLs if the file path contains reserved
702 # characters
703 # (see http://tools.ietf.org/html/rfc3986#section-2.2).
704 # See https://bugs.launchpad.net/moovida/+bug/374305 and
705 # https://bugs.launchpad.net/moovida/+bug/296517 for
706 # displays of this issue.
707 # Note that while we use MediaUri objects, the clean way to
708 # fix this mess is to make sure that file paths are
709 # correctly URL-escaped and unescaped where needed (but that
710 # would be a tedious, invasive and risky patch).
711 quoted_sub_uri = quote(sub_uri, ':/')
699 self.pipeline.set_property('suburi', quoted_sub_uri)712 self.pipeline.set_property('suburi', quoted_sub_uri)
700 self.info("Loaded subtitles at %r", sub_uri)713 self.info("Loaded subtitles at %r", quoted_sub_uri)
701 found = True714 found = True
702 break715 break
703 if not found:716 if not found:
@@ -808,8 +821,26 @@
808 self.filename = model.title or model.uri.filename821 self.filename = model.title or model.uri.filename
809 self.stop()822 self.stop()
810 uri = unicode(model.uri).encode(locale_helper.gst_file_encoding())823 uri = unicode(model.uri).encode(locale_helper.gst_file_encoding())
811 quoted_uri = quote(uri, '/:')824 if uri.startswith('file://'):
812 self.pipeline.set_property('uri', quoted_uri)825 # Hack to workaround the messy handling of file paths using MediaUri
826 # objects. In various places in the code, file paths are not
827 # URL-escaped when building a MediaUri. It results in invalid URLs
828 # if the file path contains reserved characters
829 # (see http://tools.ietf.org/html/rfc3986#section-2.2).
830 # See https://bugs.launchpad.net/moovida/+bug/374305 and
831 # https://bugs.launchpad.net/moovida/+bug/296517 for displays of
832 # this issue.
833 # Note that while we use MediaUri objects, the clean way to fix this
834 # mess is to make sure that file paths are correctly URL-escaped and
835 # unescaped where needed (but that would be a tedious, invasive and
836 # risky patch).
837 quoted_uri = quote(uri, ':/')
838 self.pipeline.set_property('uri', quoted_uri)
839 else:
840 # We quote only file:// URLs. Other MediaUri objects for distant
841 # resources are assumed to be built correctly
842 # (i.e. already URL-escaped).
843 self.pipeline.set_property('uri', uri)
813 self._load_subs(model.uri)844 self._load_subs(model.uri)
814845
815 self.update_visualization()846 self.update_visualization()

Subscribers

People subscribed via source and target branches