Yes, definite bug in Sigil code here. It looks like a really old one as well.
This regular expression to fix xml declarations in ImportEPUB.cpp is not properly restricted and it is causing the problem:
Code:
.//Misc/HTMLEncodingResolver.cpp:const QString VERSION_ATTRIBUTE = "version\\s*=\\s*(?:\"|')([^\"']+)(?:\"|')";
.//BookManipulation/XhtmlDoc.cpp:const int XML_DECLARATION_SEARCH_PREFIX_SIZE = 150;
QString ImportEPUB::PrepareOPFForReading(const QString &source)
{
QString source_copy(source);
QString prefix = source_copy.left(XML_DECLARATION_SEARCH_PREFIX_SIZE);
QRegularExpression version(VERSION_ATTRIBUTE);
QRegularExpressionMatch mo = version.match(prefix);
// MASSIVE hack for XML 1.1 "support";
// this is only for people who specify
// XML 1.1 when they actually only use XML 1.0
source_copy.replace(mo.capturedStart(), mo.capturedLength(), "version=\"1.0\"");
return source_copy;
}
This bug will hit any content.opf file that does not start with a proper xml declaration. This bug has been in Sigil for a long time. The package version tag did not matter much in earlier versions of Sigil but it does now since we need it to properly detect epub 3 from epub 2.
I will look into fixing this by restricting it to the xml declaration.
Thanks for the bug report!
KevinH