Xpra: Ticket #133: Wrong encoding in window title bars

Since version 0.2.0 the text in window titles are not valid if it contains non-Latin characters. Rolling back to version 0.1.0 allows you to get rid of the problem. Tested on Debian Squeeze (version 0.1.0 from debian-backports version 0.2.0 or higher of the http://winswitch.org/downloads/debian-repository.html) and gentoo linux.

The report prepared with the assistance tanslate.google.com



Wed, 30 May 2012 18:39:27 GMT - Alex: component changed


Wed, 30 May 2012 19:07:32 GMT - Alex:

On both systems I use python-2.6. The problem in the code xpra-client before adding the code for python-three present the following code:

82	        title = self._client.title
83	        if title.find("@")>=0:
84	            #perform metadata variable substitutions:
85	            default_values = {"title" : u"<untitled window>",
86	                              "client-machine" : u"<unknown machine>"}
87	            def metadata_replace(match):
88	                atvar = match.group(0)          #ie: '@title@'
89	                var = atvar[1:len(atvar)-1]     #ie: 'title'
90	                default_value = default_values.get(var, u"<unknown %s>" % var)
91	                return self._metadata.get(var, default_value).decode("utf-8")
92	            title = re.sub("@[\w\-]*@", metadata_replace, title)
93	        self.set_title(u"%s" % title)

In version 0.2.0 and later, the following code:

220	        title = self._client.title
221	        if title.find("@")>=0:
222	            #perform metadata variable substitutions:
223	            default_values = {"title" : u("<untitled window>"),
224	                              "client-machine" : u("<unknown machine>")}
225	            def metadata_replace(match):
226	                atvar = match.group(0)          #ie: '@title@'
227	                var = atvar[1:len(atvar)-1]     #ie: 'title'
228	                default_value = default_values.get(var, u("<unknown %s>") % var)
229	                return self._metadata.get(var, default_value)
230	            title = re.sub("@[\w\-]*@", metadata_replace, title)
231	        self.set_title(u(title))

Where u () is defined as:

169	if sys.version < '3':
170	    import codecs
171	    def u(x):
172	        return codecs.unicode_escape_decode(x)[0]
173	else:
174	    def u(x):
175	        return x

A simple hack solve the problem:

@@ -169,6 +169,7 @@
 if sys.version < '3':
     import codecs
     def u(x):
+        # return codecs.unicode_escape_decode(x)[0]
         return x
 else:
     def u(x):

But this is not the solution!


Thu, 31 May 2012 09:10:34 GMT - Antoine Martin: status changed

Will fix and release 0.3.2, can you provide a test string/command I can test with? How can I make sure that your use-case is solved?


Thu, 31 May 2012 17:52:32 GMT - Alex: attachment set


Thu, 31 May 2012 17:53:19 GMT - Alex:

I am pleased to check the patch solve this problem. I propose a simple script on pygtk, which allows output to a window caption arbitrary label. Entering non-ASCII characters, as the title of the window shows the problem.


Sat, 02 Jun 2012 16:43:16 GMT - Antoine Martin: status changed; resolution set

fixed in r880

There's a test script you can use to easily change the window title and exercise this metadata code: test_window_title.py

Many thanks for the thorough bug report!


Sat, 02 Jun 2012 17:50:47 GMT - Alex:

I confirm that no error occurs.

Sorry for my google-english.


Sat, 23 Jan 2021 04:46:26 GMT - migration script:

this ticket has been moved to: https://github.com/Xpra-org/xpra/issues/133