xpra icon
Bug tracker and wiki

This bug tracker and wiki are being discontinued
please use https://github.com/Xpra-org/xpra instead.

Opened 9 years ago

Closed 9 years ago

Last modified 9 months ago

#133 closed defect (fixed)

Wrong encoding in window title bars

Reported by: Alex Owned by: Antoine Martin
Priority: major Milestone:
Component: client Version: 0.3.x
Keywords: Cc:


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

Attachments (1)

set_caption.py (1.6 KB) - added by Alex 9 years ago.

Download all attachments as: .zip

Change History (8)

comment:1 Changed 9 years ago by Alex

Component: serverclient

comment:2 Changed 9 years ago by 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
     def u(x):

But this is not the solution!

Last edited 9 years ago by Alex (previous) (diff)

comment:3 Changed 9 years ago by Antoine Martin

Status: newaccepted

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?

Changed 9 years ago by Alex

Attachment: set_caption.py added

comment:4 Changed 9 years ago by 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.

comment:5 Changed 9 years ago by Antoine Martin

Resolution: fixed
Status: acceptedclosed

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!

comment:6 Changed 9 years ago by Alex

I confirm that no error occurs.

Sorry for my google-english.

comment:7 Changed 9 months ago by migration script

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

Note: See TracTickets for help on using tickets.