rpms/qt4/devel utf8-bug-qt4-2.diff,NONE,1.1 qt4.spec,1.40,1.41
Rex Dieter (rdieter)
fedora-extras-commits at redhat.com
Fri Mar 30 12:40:15 UTC 2007
Author: rdieter
Update of /cvs/extras/rpms/qt4/devel
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv3411
Modified Files:
qt4.spec
Added Files:
utf8-bug-qt4-2.diff
Log Message:
* Thu Mar 29 2007 Rex Dieter <rdieter[AT]fedoraproject.org> 4.2.3-7
- utf8-bug-qt4-2.diff
utf8-bug-qt4-2.diff:
--- NEW FILE utf8-bug-qt4-2.diff ---
--- src/corelib/tools/qstring.cpp
+++ src/corelib/tools/qstring.cpp
@@ -3342,6 +3342,7 @@ QString QString::fromUtf8(const char *st
result.resize(size); // worst case
ushort *qch = result.d->data;
uint uc = 0;
+ uint min_uc = 0;
int need = 0;
int error = -1;
uchar ch;
@@ -3359,6 +3360,12 @@ QString QString::fromUtf8(const char *st
ushort low = uc%0x400 + 0xdc00;
*qch++ = high;
*qch++ = low;
+ } else if ((uc < min_uc) || (uc >= 0xd800 && uc <= 0xdfff) || (uc >= 0xfffe)) {
+ // overlong seqence, UTF16 surrogate or BOM
+ i = error;
+ qch = addOne(qch, result);
+ *qch++ = 0xdbff;
+ *qch++ = 0xde00 + ((uchar)str[i]);
} else {
*qch++ = uc;
}
@@ -3381,14 +3388,17 @@ QString QString::fromUtf8(const char *st
uc = ch & 0x1f;
need = 1;
error = i;
+ min_uc = 0x80;
} else if ((ch & 0xf0) == 0xe0) {
uc = ch & 0x0f;
need = 2;
error = i;
+ min_uc = 0x800;
} else if ((ch&0xf8) == 0xf0) {
uc = ch & 0x07;
need = 3;
error = i;
+ min_uc = 0x10000;
} else {
// Error
qch = addOne(qch, result);
--- src/corelib/codecs/qutfcodec.cpp
+++ src/corelib/codecs/qutfcodec.cpp
@@ -117,15 +117,19 @@ QString QUtf8Codec::convertToUnicode(con
bool headerdone = false;
QChar replacement = QChar::ReplacementCharacter;
int need = 0;
+ int error = -1;
uint uc = 0;
+ uint min_uc = 0;
if (state) {
if (state->flags & IgnoreHeader)
headerdone = true;
if (state->flags & ConvertInvalidToNull)
replacement = QChar::Null;
need = state->remainingChars;
- if (need)
+ if (need) {
uc = state->state_data[0];
+ min_uc = state->state_data[1];
+ }
}
if (!headerdone && len > 3
&& (uchar)chars[0] == 0xef && (uchar)chars[1] == 0xbb && (uchar)chars[2] == 0xbf) {
@@ -142,7 +146,7 @@ QString QUtf8Codec::convertToUnicode(con
int invalid = 0;
for (int i=0; i<len; i++) {
- ch = *chars++;
+ ch = chars[i];
if (need) {
if ((ch&0xc0) == 0x80) {
uc = (uc << 6) | (ch & 0x3f);
@@ -153,14 +157,27 @@ QString QUtf8Codec::convertToUnicode(con
uc -= 0x10000;
unsigned short high = uc/0x400 + 0xd800;
unsigned short low = uc%0x400 + 0xdc00;
+
+ // resize if necessary
+ long where = qch - result.unicode();
+ if (where + 2 >= result.size()) {
+ result.resize(where + 2);
+ qch = result.data() + where;
+ }
+
*qch++ = QChar(high);
*qch++ = QChar(low);
+ } else if ((uc < min_uc) || (uc >= 0xd800 && uc <= 0xdfff) || (uc >= 0xfffe)) {
+ // error
+ *qch++ = QChar::ReplacementCharacter;
+ ++invalid;
} else {
*qch++ = uc;
}
}
} else {
// error
+ i = error;
*qch++ = QChar::ReplacementCharacter;
++invalid;
need = 0;
@@ -171,12 +188,22 @@ QString QUtf8Codec::convertToUnicode(con
} else if ((ch & 0xe0) == 0xc0) {
uc = ch & 0x1f;
need = 1;
+ error = i;
+ min_uc = 0x80;
} else if ((ch & 0xf0) == 0xe0) {
uc = ch & 0x0f;
need = 2;
+ error = i;
+ min_uc = 0x800;
} else if ((ch&0xf8) == 0xf0) {
uc = ch & 0x07;
need = 3;
+ error = i;
+ min_uc = 0x10000;
+ } else {
+ // error
+ *qch++ = QChar::ReplacementCharacter;
+ ++invalid;
}
}
}
@@ -187,6 +214,7 @@ QString QUtf8Codec::convertToUnicode(con
if (headerdone)
state->flags |= IgnoreHeader;
state->state_data[0] = need ? uc : 0;
+ state->state_data[1] = need ? min_uc : 0;
}
return result;
}
Index: qt4.spec
===================================================================
RCS file: /cvs/extras/rpms/qt4/devel/qt4.spec,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -r1.40 -r1.41
--- qt4.spec 23 Mar 2007 14:47:45 -0000 1.40
+++ qt4.spec 30 Mar 2007 12:39:42 -0000 1.41
@@ -13,7 +13,7 @@
Summary: Qt toolkit
Name: qt4
Version: 4.2.3
-Release: 6%{?dist}
+Release: 7%{?dist}
License: GPL/QPL
Group: System Environment/Libraries
@@ -35,6 +35,8 @@
Patch1: qt-x11-opensource-src-4.1.2-assistant4.patch
# multilib hacks
Patch2: qt-x11-opensource-src-4.2.2-multilib.patch
+#
+Patch3: utf8-bug-qt4-2.diff
## qt-copy patches
Patch0154: 0154-qdbuscpp2xml-moc_path.diff
@@ -124,9 +126,11 @@
%endif
%if "%{?sqlite:1}" != "-no-sql-sqlite"
+%if 0%{?fedora} > 2
%define _system_sqlite -system-sqlite
BuildRequires: sqlite-devel
%endif
+%endif
Obsoletes: %{name}-config < %{version}-%{release}
Provides: %{name}-config = %{version}-%{release}
@@ -218,6 +222,7 @@
%patch1 -p1 -b .assistant4
# don't use -b on mkspec files, else they get installed too.
%patch2 -p1
+%patch3 -p0 -b .utf8-bug
%patch0154 -p0 -b .qt-copy#0154
# drop -fexceptions from $RPM_OPT_FLAGS
@@ -555,6 +560,9 @@
%changelog
+* Thu Mar 29 2007 Rex Dieter <rdieter[AT]fedoraproject.org> 4.2.3-7
+- utf8-bug-qt4-2.diff
+
* Thu Mar 22 2007 Rex Dieter <rdieter[AT]fedoraproject.org> 4.2.3-6
- -system-sqlite, BR: sqlite-devel
- drop mysql_config hackery
More information about the fedora-extras-commits
mailing list