Fix QAbstractFileEngine read and readLine methods to accept data with null bytes.
Reviewer: Marcelo Lira <marcelo.lira@openbossa.org>
Renato Araújo <renato.filho@openbossa.org>
This commit is contained in:
parent
8e43e10f4e
commit
e9de49255b
2 changed files with 4 additions and 5 deletions
|
|
@ -2363,7 +2363,7 @@
|
||||||
%out = -1;
|
%out = -1;
|
||||||
} else {
|
} else {
|
||||||
%out = PyString_GET_SIZE((PyObject*)%PYARG_0);
|
%out = PyString_GET_SIZE((PyObject*)%PYARG_0);
|
||||||
qstrncpy(%1, PyString_AS_STRING((PyObject*)%PYARG_0), %out + 1);
|
memcpy(%1, PyString_AS_STRING((PyObject*)%PYARG_0), %out);
|
||||||
}
|
}
|
||||||
</conversion-rule>
|
</conversion-rule>
|
||||||
</modify-argument>
|
</modify-argument>
|
||||||
|
|
@ -2386,7 +2386,7 @@
|
||||||
%out = -1;
|
%out = -1;
|
||||||
} else {
|
} else {
|
||||||
%out = PyString_GET_SIZE((PyObject*)%PYARG_0);
|
%out = PyString_GET_SIZE((PyObject*)%PYARG_0);
|
||||||
qstrncpy(%1, PyString_AS_STRING((PyObject*)%PYARG_0), %out + 1);
|
memcpy(%1, PyString_AS_STRING((PyObject*)%PYARG_0), %out);
|
||||||
}
|
}
|
||||||
</conversion-rule>
|
</conversion-rule>
|
||||||
</modify-argument>
|
</modify-argument>
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ class MyFileEngine (QAbstractFileEngine):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
QAbstractFileEngine.__init__(self)
|
QAbstractFileEngine.__init__(self)
|
||||||
self.contents = "Foo bar for the win!"
|
self.contents = "Foo \0bar for the win!"
|
||||||
self.pos = 0
|
self.pos = 0
|
||||||
|
|
||||||
def open(self, mode):
|
def open(self, mode):
|
||||||
|
|
@ -27,7 +27,6 @@ class MyFileEngine (QAbstractFileEngine):
|
||||||
class MyFileEngineHandler (QAbstractFileEngineHandler):
|
class MyFileEngineHandler (QAbstractFileEngineHandler):
|
||||||
|
|
||||||
def create(self, fileName):
|
def create(self, fileName):
|
||||||
print "hey ho: ", fileName
|
|
||||||
if fileName.startswith("foo:/"):
|
if fileName.startswith("foo:/"):
|
||||||
return MyFileEngine()
|
return MyFileEngine()
|
||||||
return None
|
return None
|
||||||
|
|
@ -42,7 +41,7 @@ class TestBug723 (unittest.TestCase):
|
||||||
|
|
||||||
assert(f.open(QFile.ReadOnly | QFile.Text))
|
assert(f.open(QFile.ReadOnly | QFile.Text))
|
||||||
contents = f.readAll()
|
contents = f.readAll()
|
||||||
self.assertEqual(contents, "Foo bar for the win!")
|
self.assertEqual(contents, "Foo \0bar for the win!")
|
||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue