Changes between Initial Version and Version 1 of Ticket #1355


Ignore:
Timestamp:
Feb 14, 2006, 9:08:14 AM (18 years ago)
Author:
hugo
Comment:

The problem here: we can't assume anything about the filesystem of the server beside the fact that it is possible to use us-ascii in filenames. So utf-8 won't be an option - it might produce unreadable filenames. And since there are several places that function like / and ., we can't just accept any char we want, or we would open up for filesystem traversal hackery.

One way would be to just turn non-ascii chars into a uXXXX form, so that at least the filename isn't all dashes.

I move the database stuff into it's own ticket, as that isn't i18n related, but more database backend related.

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #1355 – Description

    initial v1  
    1 1. The function django.utils.text.get_valid_filename() is not friendly for non-latin file-names
     1The function django.utils.text.get_valid_filename() is not friendly for non-latin file-names
    22{{{
    33    s = s.strip().replace(' ', '_')
     
    1313Or make it possible to overload this function to end-programmer.
    1414
    15 2. In django.core.db.backends.mysql.DatabaseWrapper in method cursor()
    16 When you doing
    17 {{{
    18             self.connection = Database.connect(**kwargs)
    19         cursor = self.connection.cursor()
    20         if self.connection.get_server_info() >= '4.1':
    21             cursor.execute("SET NAMES 'utf8'")
    22 }}}
    23 After 'set names ..' the charset of connection was changed.
    24 But self.connection.charset property (property of MySQLdb.connection) was not changed. It is always 'Latin1'
    25 So, when i pass u"unicode national characters" into database, MySQLdb tryed to convert it into Latin1 and exception raises
    26 
    27 To fix it, i must set .charset propery manually:
    28 {{{
    29 ...
    30             self.connection = Database.connect(**kwargs)
    31             self.connection.charset = 'utf8'
    32         cursor = self.connection.cursor()
    33         if self.connection.get_server_info() >= '4.1':
    34             cursor.execute("SET NAMES 'utf8'")
    35 ...
    36 }}}
    37 
Back to Top