[pitivi/1.0] project: Unquote name property



commit 767374b3a8fd8b899dcf7377ad3dbe57092c00b9
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 7b458379..8fb127a4 100644
--- a/pitivi/project.py
+++ b/pitivi/project.py
@@ -25,6 +25,7 @@ import tarfile
 import time
 import uuid
 from gettext import gettext as _
+from urllib.parse import unquote
 
 from gi.repository import GES
 from gi.repository import GLib
@@ -761,7 +762,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 7e99ee8f..9b0647b9 100644
--- a/tests/test_project.py
+++ b/tests/test_project.py
@@ -660,6 +660,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]