qmake can not process project file with UTF-8 BOM
authorDebao Zhang <dbzhang800@gmail.com>
Tue, 22 May 2012 16:55:03 +0000 (09:55 -0700)
committerQt by Nokia <qt-info@nokia.com>
Tue, 29 May 2012 23:54:45 +0000 (01:54 +0200)
Project file contains UTF-8 BOM can't processesed by qmake and will
cause subtle errors.

Task-number: QTBUG-25848
Change-Id: Id69ed38c6be63a29fa3792a631cb8cb0ac176148
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
qmake/project.cpp

index 9716237..3df80bc 100644 (file)
@@ -1239,8 +1239,14 @@ QMakeProject::read(const QString &file, QHash<QString, QStringList> &place)
         parser.from_file = true;
         parser.file = filename;
         parser.line_no = 0;
-        QTextStream t(&qfile);
-        ret = read(t, place);
+        if (qfile.peek(3) == QByteArray("\xef\xbb\xbf")) {
+            //UTF-8 BOM will cause subtle errors
+            qmake_error_msg("Unexpected UTF-8 BOM found");
+            ret = false;
+        } else {
+            QTextStream t(&qfile);
+            ret = read(t, place);
+        }
         if(!using_stdin)
             qfile.close();
     }