[pitivi] project: Unquote name property



commit 54c1dc08833a9923ca6615f06f1258872919776d
Author: Yetizone <andreii lisita gmail com>
Date:   Fri Feb 8 13:09:22 2019 +0200

    project: Unquote name property
    
    Fixes #2264

 pitivi/project.py     | 4 +++-
 tests/test_project.py | 9 +++++++++
 2 files changed, 12 insertions(+), 1 deletion(-)
---
diff --git a/pitivi/project.py b/pitivi/project.py
index 7469d72f..d1158b4b 100644
--- a/pitivi/project.py
+++ b/pitivi/project.py
@@ -27,6 +27,7 @@ import time
 import uuid
 from gettext import gettext as _
 from hashlib import md5
+from urllib.parse import unquote
 
 from gi.repository import GdkPixbuf
 from gi.repository import GES
@@ -765,7 +766,8 @@ class Project(Loggable, GES.Project):
     def name(self):
         if not self.uri:
             return DEFAULT_NAME
-        return os.path.splitext(os.path.basename(self.uri))[0]
+        quoted_name = os.path.splitext(os.path.basename(self.uri))[0]
+        return unquote(quoted_name)
 
     @property
     def year(self):
diff --git a/tests/test_project.py b/tests/test_project.py
index 8f9a267a..c3333b33 100644
--- a/tests/test_project.py
+++ b/tests/test_project.py
@@ -625,6 +625,15 @@ class TestProjectSettings(common.TestCase):
         self.assertFalse(project._has_default_video_settings)
         self.assertFalse(project._has_default_audio_settings)
 
+    def test_name(self):
+        project = Project(common.create_pitivi_mock())
+
+        project.uri = "file:///tmp/A%20B.xges"
+        self.assertEqual(project.name, "A B")
+
+        project.uri = "file:///tmp/%40%23%24%5E%26%60.xges"
+        self.assertEqual(project.name, "@#$^&`")
+
 
 class TestExportSettings(common.TestCase):
 


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