national special characters in username (vista64) fail for sabnzbd 4.11

Report & discuss bugs found in SABnzbd
Forum rules
Help us help you:
  • Are you using the latest stable version of SABnzbd? Downloads page.
  • Tell us what system you run SABnzbd on.
  • Adhere to the forum rules.
  • Do you experience problems during downloading?
    Check your connection in Status and Interface settings window.
    Use Test Server in Config > Servers.
    We will probably ask you to do a test using only basic settings.
  • Do you experience problems during repair or unpacking?
    Enable +Debug logging in the Status and Interface settings window and share the relevant parts of the log here using [ code ] sections.
Post Reply
guru1968
Newbie
Newbie
Posts: 11
Joined: July 8th, 2009, 6:11 pm

national special characters in username (vista64) fail for sabnzbd 4.11

Post by guru1968 »

Hello...
I am from Germany and my name is "Jörg", so my Profile-dirs (Vista64) start with 'C:\\Users\\Jörg'
this special character 'ö' makes SABnzbd 4.11 fail to show the config page because the treatment of special characters in the GetProfileInfo function is wrong:
first bug: the 8bit ASCII conversion needed for CherryPy is only done when the Get_User_ShellFolders() failed - it must be done in any case, because this function also could have delivered UNICODE character(s) necessary to be converted...
second bug: when all failed, win32api.GetShortPathName() is called, BUT: with DEF_WORKDIR already appended - that function only works for existing pathnames, so when this directory doesn't exist yet (first call after installation) it fails!

here's how I changed it to work at least for me:

    elif os.name == 'nt':
        specials = Get_User_ShellFolders()
        try:
            sabnzbd.DIR_APPDATA = '%s' % specials['AppData']
            sabnzbd.DIR_LCLDATA = '%s' % specials['Local AppData']
            sabnzbd.DIR_HOME = specials['Personal']
        except:
            try:
                if vista:
                    root = os.environ['AppData']
                    user = os.environ['USERPROFILE']
                    sabnzbd.DIR_APPDATA = '%s' % root.replace('\\Roaming', '\\Local')
                    sabnzbd.DIR_HOME    = '%s\\Documents' % user
                else:
                    root = os.environ['USERPROFILE']
                    sabnzbd.DIR_APPDATA = '%s' % root
                    sabnzbd.DIR_HOME = root

            except:
                pass

        try:
            # Conversion to 8bit ASCII required for CherryPy
            sabnzbd.DIR_APPDATA = sabnzbd.DIR_APPDATA.encode('latin-1')
            sabnzbd.DIR_HOME = sabnzbd.DIR_HOME.encode('latin-1')
            ok = True
        except:
            # If unconvertible characters exist, use MSDOS name
            try:
                sabnzbd.DIR_APPDATA = win32api.GetShortPathName(sabnzbd.DIR_APPDATA)
                sabnzbd.DIR_HOME = win32api.GetShortPathName(sabnzbd.DIR_HOME)
                ok = True
            except:
                pass
        sabnzbd.DIR_APPDATA = '%s\\%s' % (sabnzbd.DIR_APPDATA, DEF_WORKDIR.encode('latin-1'))
        sabnzbd.DIR_HOME = '%s\\%s' % (sabnzbd.DIR_HOME, DEF_WORKDIR.encode('latin-1'))
        sabnzbd.DIR_LCLDATA = sabnzbd.DIR_APPDATA
User avatar
shypike
Administrator
Administrator
Posts: 19774
Joined: January 18th, 2008, 12:49 pm

Re: national special characters in username (vista64) fail for sabnzbd 4.11

Post by shypike »

Looks like sensible changes, will take that up asap.
Thanks.

The odd things is that we did test with accented characters in profile names.
An error must have crept in later.

One day (when enough third-party modules have been ported) we'll switch to
Python 3 and create a full Unicode app.
User avatar
shypike
Administrator
Administrator
Posts: 19774
Joined: January 18th, 2008, 12:49 pm

Re: national special characters in username (vista64) fail for sabnzbd 4.11

Post by shypike »

A work-around is to use the -f parameter.
Modify the shortcut to SABnzbd to read:

Code: Select all

"c:\program files\SAbnzbd\SABnzbd.exe -f c:\users\ORG~1\sabnzbd.ini
The "ORG~1" part is the 8.3 limited part of the path that you will see
when you type this in a command prompt:

Code: Select all

dir /x c:\users
It could be slightly different.
User avatar
shypike
Administrator
Administrator
Posts: 19774
Joined: January 18th, 2008, 12:49 pm

Re: national special characters in username (vista64) fail for sabnzbd 4.11

Post by shypike »

guru1968 wrote: first bug: the 8bit ASCII conversion needed for CherryPy is only done when the Get_User_ShellFolders() failed - it must be done in any case, because this function also could have delivered UNICODE character(s) necessary to be converted...
second bug: when all failed, win32api.GetShortPathName() is called, BUT: with DEF_WORKDIR already appended - that function only works for existing pathnames, so when this directory doesn't exist yet (first call after installation) it fails!
The first bug does not exist.
The function Get_User_ShellFolders() always returns 8bit ASCII strings, the 'latin-1' conversion is already done there.

The second bug is real, so this must be the one you're bitten by.
The odd thing is that the 'ö' should be encodable in 8bit ASCII, unless you chose a different representation that can only be encoded in Unicode.
Does SABnzbd show short paths in Config->General?
User avatar
shypike
Administrator
Administrator
Posts: 19774
Joined: January 18th, 2008, 12:49 pm

Re: national special characters in username (vista64) fail for sabnzbd 4.11

Post by shypike »

Actually when I test on Vista with account names "Jörg" and "€uro", its works fine.
"Jörg" works fine and it shows properly in Config.
"€uro" cannot be converted to 8bit ASCII and therefore shows up in Config as "C:\Users\URO~1\...".
Neither account name makes SABnzbd fail.

Which codepage do you use on your system and how is the "ö" encoded?
Has it been entered using Alt-0246?
Post Reply