Fix Python's handling of nsACString's with embedded null bytes.
Not part of the default build. git-svn-id: svn://10.0.0.236/trunk@213667 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -115,12 +115,17 @@ PyObject_FromNSString( const nsACString &s, PRBool bAssumeUTF8 /*= PR_FALSE */)
|
||||
const nsCString temp(s);
|
||||
ret = PyUnicode_DecodeUTF8(temp.get(), temp.Length(), NULL);
|
||||
} else {
|
||||
ret = PyString_FromStringAndSize(NULL, s.Length());
|
||||
nsAString::size_type len = s.Length();
|
||||
ret = PyString_FromStringAndSize(NULL, len);
|
||||
if (!ret)
|
||||
return NULL;
|
||||
// Need "CopyAsciiTo"!?
|
||||
char* dest = PyString_AS_STRING(ret);
|
||||
PL_strncpy(dest, s.BeginReading(), s.Length());
|
||||
// Need "CopyAsciiTo"!? Worse - since libxul,
|
||||
// nsACString appears to have no const_iterator!
|
||||
char* dest = PyString_AS_STRING(ret);
|
||||
nsAString::size_type i;
|
||||
for (i=0;i<len;i++)
|
||||
dest[i] = s[i];
|
||||
// Python string pre-terminated when created - so done!
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
|
||||
Reference in New Issue
Block a user