Not-English characters in path break scoring function

Bug #537730 reported by Alexey Porotnikov
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
kupfer
Fix Released
Undecided
Unassigned

Bug Description

I have LANG=ru_RU.UTF-8 and much *.desktop files in the directory ~/.local/share/applications/wine/Программы, created by WINE.
"Программы" it "Programs" in Russian. And kupfer with some circumstances enters catalepsy, making a log

Traceback (most recent call last):
  File "/home/user/workspace/kupfer/src/kupfer/core/data.py", line 290, in search
    decorator=decorator)
  File "/home/user/workspace/kupfer/src/kupfer/core/data.py", line 118, in search
    reverse=True)
  File "/home/user/workspace/kupfer/src/kupfer/core/search.py", line 45, in bonus_objects
    for obj in rankables:
  File "/home/user/workspace/kupfer/src/kupfer/core/search.py", line 69, in score_objects
    arank = _score(alias, key)*95
  File "/home/user/workspace/kupfer/src/kupfer/core/relevance.py", line 138, in score
    if ls[i + 1] in query:
TypeError: 'in <string>' requires string as left operand

The crash of scoring function happens, if the analysis of initial characters of words receives the cyrillic character ("П" in this case) after a hyphen or a blank in the folded application name that is if the previous pressed character has been found to the left of this combination of characters and the current character is found to the right of a combination.

ls[i+1] gives the first byte of utf-8 representation (0xd0 for "П"), but not the first character of a word.

The error does not arise under following conditions
I have moved the "Программы" from a field of view - the error does not arise.
I have returned "Программы" and have renamed to "Programs" - the error does not arise.
I have renamed "Программы" to "0Программы" - the error does not arise.

description: updated
Revision history for this message
X (u78qir8a9-deactivatedaccount) wrote :

Thanks for reporting bugs with Kupfer, encoding bugs are important.

I can't reproduce something exactly like that here. However the traceback suggests that the error comes from the *alias* of a program, and what I can see in the code these aliases are not handled correctly with respect to filesystem (filename) encoding. So I have a proposed fix for that problem, I hope that this solves it for you:

http://git.gnome.org/browse/kupfer/commit/?id=43d59a2898559249894a2c14b1875ee878395ecd

Changed in kupfer:
assignee: nobody → Ulrik Sverdrup (ulrik-sverdrup)
Revision history for this message
Alexey Porotnikov (aalpo) wrote :

Yes, it has solved this problem.
Before the patch, "score" function received as first argument mix of bytestrings and unicode strings, and after only unicode.

Revision history for this message
X (u78qir8a9-deactivatedaccount) wrote :

Thanks for confirming the fix! Maybe/hopefully kupfer should be more robust and we should proactively guard against this situation.

Changed in kupfer:
status: New → Fix Committed
Changed in kupfer:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.