|
Lines 1302-1316
inline int QXmlStreamReaderPrivate::fastScanContentCharList()
Link Here
|
| 1302 |
return n; |
1302 |
return n; |
| 1303 |
} |
1303 |
} |
| 1304 |
|
1304 |
|
| 1305 |
inline int QXmlStreamReaderPrivate::fastScanName(int *prefix) |
1305 |
// Fast scan an XML attribute name (e.g. "xml:lang"). |
|
|
1306 |
inline QXmlStreamReaderPrivate::FastScanNameResult |
| 1307 |
QXmlStreamReaderPrivate::fastScanName(Value *val) |
| 1306 |
{ |
1308 |
{ |
| 1307 |
int n = 0; |
1309 |
int n = 0; |
| 1308 |
uint c; |
1310 |
uint c; |
| 1309 |
while ((c = getChar()) != StreamEOF) { |
1311 |
while ((c = getChar()) != StreamEOF) { |
| 1310 |
if (n >= 4096) { |
1312 |
if (n >= 4096) { |
| 1311 |
// This is too long to be a sensible name, and |
1313 |
// This is too long to be a sensible name, and |
| 1312 |
// can exhaust memory |
1314 |
// can exhaust memory, or the range of decltype(*prefix) |
| 1313 |
return 0; |
1315 |
raiseNamePrefixTooLongError(); |
|
|
1316 |
return {}; |
| 1314 |
} |
1317 |
} |
| 1315 |
switch (c) { |
1318 |
switch (c) { |
| 1316 |
case '\n': |
1319 |
case '\n': |
|
Lines 1339-1361
inline int QXmlStreamReaderPrivate::fastScanName(int *prefix)
Link Here
|
| 1339 |
case '+': |
1342 |
case '+': |
| 1340 |
case '*': |
1343 |
case '*': |
| 1341 |
putChar(c); |
1344 |
putChar(c); |
| 1342 |
if (prefix && *prefix == n+1) { |
1345 |
if (val && val->prefix == n + 1) { |
| 1343 |
*prefix = 0; |
1346 |
val->prefix = 0; |
| 1344 |
putChar(':'); |
1347 |
putChar(':'); |
| 1345 |
--n; |
1348 |
--n; |
| 1346 |
} |
1349 |
} |
| 1347 |
return n; |
1350 |
return FastScanNameResult(n); |
| 1348 |
case ':': |
1351 |
case ':': |
| 1349 |
if (prefix) { |
1352 |
if (val) { |
| 1350 |
if (*prefix == 0) { |
1353 |
if (val->prefix == 0) { |
| 1351 |
*prefix = n+2; |
1354 |
val->prefix = n + 2; |
| 1352 |
} else { // only one colon allowed according to the namespace spec. |
1355 |
} else { // only one colon allowed according to the namespace spec. |
| 1353 |
putChar(c); |
1356 |
putChar(c); |
| 1354 |
return n; |
1357 |
return FastScanNameResult(n); |
| 1355 |
} |
1358 |
} |
| 1356 |
} else { |
1359 |
} else { |
| 1357 |
putChar(c); |
1360 |
putChar(c); |
| 1358 |
return n; |
1361 |
return FastScanNameResult(n); |
| 1359 |
} |
1362 |
} |
| 1360 |
Q_FALLTHROUGH(); |
1363 |
Q_FALLTHROUGH(); |
| 1361 |
default: |
1364 |
default: |
|
Lines 1364-1375
inline int QXmlStreamReaderPrivate::fastScanName(int *prefix)
Link Here
|
| 1364 |
} |
1367 |
} |
| 1365 |
} |
1368 |
} |
| 1366 |
|
1369 |
|
| 1367 |
if (prefix) |
1370 |
if (val) |
| 1368 |
*prefix = 0; |
1371 |
val->prefix = 0; |
| 1369 |
int pos = textBuffer.size() - n; |
1372 |
int pos = textBuffer.size() - n; |
| 1370 |
putString(textBuffer, pos); |
1373 |
putString(textBuffer, pos); |
| 1371 |
textBuffer.resize(pos); |
1374 |
textBuffer.resize(pos); |
| 1372 |
return 0; |
1375 |
return FastScanNameResult(0); |
| 1373 |
} |
1376 |
} |
| 1374 |
|
1377 |
|
| 1375 |
enum NameChar { NameBeginning, NameNotBeginning, NotName }; |
1378 |
enum NameChar { NameBeginning, NameNotBeginning, NotName }; |
|
Lines 1878-1883
void QXmlStreamReaderPrivate::raiseWellFormedError(const QString &message)
Link Here
|
| 1878 |
raiseError(QXmlStreamReader::NotWellFormedError, message); |
1881 |
raiseError(QXmlStreamReader::NotWellFormedError, message); |
| 1879 |
} |
1882 |
} |
| 1880 |
|
1883 |
|
|
|
1884 |
void QXmlStreamReaderPrivate::raiseNamePrefixTooLongError() |
| 1885 |
{ |
| 1886 |
// TODO: add a ImplementationLimitsExceededError and use it instead |
| 1887 |
raiseError(QXmlStreamReader::NotWellFormedError, |
| 1888 |
QXmlStream::tr("Length of XML attribute name exceeds implemnetation limits (4KiB " |
| 1889 |
"characters).")); |
| 1890 |
} |
| 1891 |
|
| 1881 |
void QXmlStreamReaderPrivate::parseError() |
1892 |
void QXmlStreamReaderPrivate::parseError() |
| 1882 |
{ |
1893 |
{ |
| 1883 |
|
1894 |
|