Bugs item #3323058, was opened at 2011-06-20 07:19
Message generated for change (Comment added) made by rupole
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=551954&aid=3323058&group_id=78018
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: win32
Group: None
Status: Pending
Resolution: None
Priority: 5
Private: No
Submitted By: mandel ()
Assigned to: Nobody/Anonymous (nobody)
Summary: GetFileSecurity & SetFileSecurity do not support UTF8 paths
Initial Comment:
The GetFileSecurity and SetSecurity method are using the non utf8 versions of the COM API. The simples way to fix the issue is to use the UTF8 versions of the functions (GetFileSecurityW, SetFileSecurityW).
----------------------------------------------------------------------
>Comment By: Roger Upole (rupole)
Date: 2011-06-24 12:12
Message:
That code works here. Can you please provide a complete traceback ?
Also, what versions of Python and Pywin32 are you running ?
If the function had been using the plain char api's, and this patch was
applied, the code should fail to compile due to passing a char * to a
funtion that requires WCHAR *. And again, the *W versions of these
functions do *not* use utf8. Wide character is a 2-byte encoding, whereas
utf8 is a single byte encoding with a continuation indicator.
----------------------------------------------------------------------
Comment By: mandel ()
Date: 2011-06-24 09:08
Message:
For what I was able to test if I used valid unicode chars in the path the
calls to GetFileSecurity from win32security would return na exception. Here
is an example of valid code that would not work:
>>> from win32security import GetFileSecurity, DACL_SECURITY_INFORMATION
>>> file_name = u'test_file\u200b\u2033\u200b\u200b\u203d\u200b\u200b'
>>> open(file_name, 'wb').close()
>>> GetFileSecurity(file_name, DACL_SECURITY_INFORMATION)
Running the above code create a test file that does have utf8 chars. Once
that file is created the GetFileSecurity raises an exception complaining
about the path. On the other hand with the given patch the code works as
expected.
----------------------------------------------------------------------
Comment By: Roger Upole (rupole)
Date: 2011-06-21 15:25
Message:
The win32security module is built with UNICODE defined, so it's already
calling
GetFileSecurityW and SetFileSecurityW. Also, these functions use WCHAR
rather than utf8.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=551954&aid=3323058&group_id=78018
|