[pitivi] utils/misc: Use Gst.filename_to_uri instead of manually encoding URIs



commit 89dc28efae37f5c29c5b85b392833343021f5c9b
Author: Jean-FranÃois Fortin Tam <nekohayo gmail com>
Date:   Tue Jan 22 16:55:30 2013 -0500

    utils/misc: Use Gst.filename_to_uri instead of manually encoding URIs
    
    Fixes bug #692331, ensuring that we can find the thumbnails for all files

 pitivi/utils/misc.py |   19 +++++++------------
 1 files changed, 7 insertions(+), 12 deletions(-)
---
diff --git a/pitivi/utils/misc.py b/pitivi/utils/misc.py
index 8d4170b..4f7716a 100644
--- a/pitivi/utils/misc.py
+++ b/pitivi/utils/misc.py
@@ -174,20 +174,15 @@ def path_from_uri(uri):
 
 def quote_uri(uri):
     """
-    Encode a URI according to RFC 2396, without touching the file:/// part.
+    Encode a URI/path according to RFC 2396, without touching the file:/// part.
     """
-    parts = list(urlsplit(uri, allow_fragments=False))
+    # Split off the "file:///" part, if present.
+    parts = urlsplit(uri, allow_fragments=False)
     # Make absolutely sure the string is unquoted before quoting again!
-    raw = unquote(parts[2])
-    # For computing thumbnail md5 hashes in the source list, we must adhere to
-    # RFC 2396. However, urllib's quote method only uses alphanumeric and "/"
-    # as their safe chars. We need to add both the reserved and unreserved chars
-    RFC_2396_RESERVED = ";/?:@&=+$,"
-    RFC_2396_UNRESERVED = "-_.!~*'()"
-    URIC_SAFE_CHARS = "/" + "%" + RFC_2396_RESERVED + RFC_2396_UNRESERVED
-    parts[2] = quote(raw, URIC_SAFE_CHARS)
-    uri = urlunsplit(parts)
-    return uri
+    raw_path = unquote(parts.path)
+    # For computing thumbnail md5 hashes in the media library, we must adhere to
+    # RFC 2396. It is quite tricky to handle all corner cases, leave it to Gst:
+    return Gst.filename_to_uri(raw_path)
 
 
 class PathWalker(Thread):



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]