summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--ranger/fsobject/fsobject.py9
-rw-r--r--ranger/gui/ui.py6
2 files changed, 8 insertions, 7 deletions
diff --git a/ranger/fsobject/fsobject.py b/ranger/fsobject/fsobject.py
index 1d1f202d..943c8aa4 100644
--- a/ranger/fsobject/fsobject.py
+++ b/ranger/fsobject/fsobject.py
@@ -30,10 +30,13 @@ if hasattr(str, 'maketrans'):
 	maketrans = str.maketrans
 else:
 	from string import maketrans
-unsafe_chars = '\n' + ''.join(map(chr, range(32))) + ''.join(map(chr, range(128, 256)))
-safe_string_table = maketrans(unsafe_chars, '?' * len(unsafe_chars))
+_unsafe_chars = '\n' + ''.join(map(chr, range(32))) + ''.join(map(chr, range(128, 256)))
+_safe_string_table = maketrans(_unsafe_chars, '?' * len(_unsafe_chars))
 _extract_number_re = re.compile(r'([^0-9]?)(\d*)')
 
+def safe_path(path):
+	return path.translate(_safe_string_table)
+
 class FileSystemObject(FileManagerAware):
 	(basename,
 	basename_lower,
@@ -114,7 +117,7 @@ class FileSystemObject(FileManagerAware):
 
 	@lazy_property
 	def safe_basename(self):
-		return self.basename.translate(safe_string_table)
+		return self.basename.translate(_safe_string_table)
 
 
 	for attr in ('video', 'audio', 'image', 'media', 'document', 'container'):
diff --git a/ranger/gui/ui.py b/ranger/gui/ui.py
index 91d0d774..064d4a16 100644
--- a/ranger/gui/ui.py
+++ b/ranger/gui/ui.py
@@ -21,6 +21,7 @@ import _curses
 from .displayable import DisplayableContainer
 from .mouse_event import MouseEvent
 from ranger.ext.keybinding_parser import ALT_KEY
+from ranger.fsobject.fsobject import safe_path
 
 TERMINALS_WITH_TITLE = ("xterm", "xterm-256color", "rxvt",
 		"rxvt-256color", "rxvt-unicode", "aterm", "Eterm",
@@ -293,10 +294,7 @@ class UI(DisplayableContainer):
 				split = cwd.rsplit(os.sep, self.settings.shorten_title)
 				if os.sep in split[0]:
 					cwd = os.sep.join(split[1:])
-			try:
-				sys.stdout.write("\033]2;ranger:" + cwd + "\007")
-			except UnicodeEncodeError:
-				sys.stdout.write("\033]2;ranger:" + ascii_only(cwd) + "\007")
+			sys.stdout.write("\033]2;ranger:" + safe_path(cwd) + "\007")
 		self.win.refresh()
 
 	def finalize(self):
pre>cec5ef31 ^
30012350 ^
cec5ef31 ^
5c058ad6 ^


bae22d72 ^


30012350 ^
cec5ef31 ^
30012350 ^
cec5ef31 ^
1694f9a3 ^

30012350 ^




34ac52cb ^
30012350 ^
cec5ef31 ^
30012350 ^



cec5ef31 ^
bae22d72 ^
492fb278 ^






















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69