Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Sigil

Notices

Reply
 
Thread Tools Search this Thread
Old 02-21-2016, 03:56 PM   #1
nalor78
Junior Member
nalor78 began at the beginning.
 
Posts: 6
Karma: 10
Join Date: Aug 2010
Location: Austria
Device: Onyx Boox AfterGlow C65ML
Question sigil changes 'version' in content.opf from 2.0 to 1.0?

Today I noticed something strange - when I open one of my epubs in sigil 0.9.3 (or previously in 0.8.x) and check the content.opf the first lines look like this:

Quote:
<?xml version="1.0" encoding="utf-8" ?>
<package unique-identifier="isbn9783401804651" version="1.0" xmlns="http://www.idpf.org/2007/opf">
But when I open the identical epub file with 7zip and open the file 'OPS/9781234567890.opf' the first lines look different:

Quote:
<package xmlns="http://www.idpf.org/2007/opf" unique-identifier="isbn9783401804651" version="2.0">
So why does Sigil change the version number from '2.0' in the original file to '1.0'

I've attached an epub to show the problem (I've removed all picture and text files from the epub - so it's really small).

Thanks for your help!
Attached Files
File Type: epub Epub-Version2.0to1.0.epub (5.2 KB, 214 views)

Last edited by nalor78; 02-21-2016 at 03:57 PM. Reason: added sigil version
nalor78 is offline   Reply With Quote
Old 02-21-2016, 04:06 PM   #2
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
Posts: 27,552
Karma: 193191846
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
I see what you're saying saying with THAT epub. But I've never seen it happen with any other epub (v2 or v3) with Sigil 0.9.3. But then again, I've never opened any epubs with no text files. Will have to take a closer look.
DiapDealer is offline   Reply With Quote
Advert
Old 02-21-2016, 04:30 PM   #3
nalor78
Junior Member
nalor78 began at the beginning.
 
Posts: 6
Karma: 10
Join Date: Aug 2010
Location: Austria
Device: Onyx Boox AfterGlow C65ML
Smile

If you want I can send you the original epub, I just don't want to post it directly in public.
Sigil behaves exactly the same way with the original file - so I don't think it will make a big difference in the end.

Thanks for looking into the issue!
nalor78 is offline   Reply With Quote
Old 02-21-2016, 04:49 PM   #4
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
Posts: 27,552
Karma: 193191846
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
Quote:
Originally Posted by nalor78 View Post
If you want I can send you the original epub, I just don't want to post it directly in public.
No thank you. I don't want a copy if it's a copyrighted book. There's a calibre plugin that will scramble the contents of an epub which will allow you to post a copy while avoiding any copyright issues. A scrambled version should allow us to see what's different about that epub. That would be my preference, if possible.
DiapDealer is offline   Reply With Quote
Old 02-21-2016, 05:30 PM   #5
KevinH
Sigil Developer
KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.
 
Posts: 7,647
Karma: 5433388
Join Date: Nov 2009
Device: many
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

Last edited by KevinH; 02-21-2016 at 08:51 PM.
KevinH is online now   Reply With Quote
Advert
Old 02-21-2016, 06:50 PM   #6
KevinH
Sigil Developer
KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.
 
Posts: 7,647
Karma: 5433388
Join Date: Nov 2009
Device: many
Hi All,

This bug is now fixed in Sigil master. It will hit any OPF file that does not start with an xml declaration line:

Code:
<?xml version="1.0" encoding="utf-8" ?>
So the workaround is to edit the opf file and add an xml declaration to the first line of the file. Sigil does this automatically which is why we have not seen this bug reported before.

This bug fix will appear in the next release.

KevinH
KevinH is online now   Reply With Quote
Old 02-21-2016, 07:11 PM   #7
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
Posts: 27,552
Karma: 193191846
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
Thanks Kevin!

I'm guessing this explains the post in the Sigil v0.9.3 release thread (which prompted the FixOPFv1 plugin) where people were running into opf package version "1.0" epubs (pre-existing epubs) so often. Sounds like this bug has been making people think there's way more plugins out there with incorrect package versions than there really are, for a very long time!
DiapDealer is offline   Reply With Quote
Old 02-21-2016, 08:58 PM   #8
KevinH
Sigil Developer
KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.
 
Posts: 7,647
Karma: 5433388
Join Date: Nov 2009
Device: many
Hi DiapDealer,
Since the next release of Sigil is still weeks away (I have a lot of semantic and nav landmark changes to make yet), would you please modify your fixv1 plugin to change 1 to 2 as well as pass through version 2.0 and 3.0 unchanged but make sure you add a xml declaration heading to the opf file if it is missing.

That will help people load in epubs not created in Sigil until we get a new release out. Either that or we can pull the Sigil-0.9.3 tag and add just the bug fixes and release a Sigil 0.9.3b version.

Thanks!

KevinH


Quote:
Originally Posted by DiapDealer View Post
Thanks Kevin!

I'm guessing this explains the post in the Sigil v0.9.3 release thread (which prompted the FixOPFv1 plugin) where people were running into opf package version "1.0" epubs (pre-existing epubs) so often. Sounds like this bug has been making people think there's way more plugins out there with incorrect package versions than there really are, for a very long time!
KevinH is online now   Reply With Quote
Old 02-21-2016, 09:03 PM   #9
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
Posts: 27,552
Karma: 193191846
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
Quote:
Originally Posted by KevinH View Post
Hi DiapDealer,
Since the next release of Sigil is still weeks away (I have a lot of semantic and nav landmark changes to make yet), would you please modify your fixv1 plugin to change 1 to 2 as well as pass through version 2.0 and 3.0 unchanged but make sure you add a xml declaration heading to the opf file if it is missing.

That will help people load in epubs not created in Sigil until we get a new release out. Either that or we can pull the Sigil-0.9.3 tag and add just the bug fixes and release a Sigil 0.9.3b version.

Thanks!

KevinH
Not a problem. I'm already on it.
DiapDealer is offline   Reply With Quote
Old 02-21-2016, 09:18 PM   #10
KevinH
Sigil Developer
KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.
 
Posts: 7,647
Karma: 5433388
Join Date: Nov 2009
Device: many
Hi DiapDealer,
Should we push out a Sigil-0.9.3b or Sigil-0.9.3v2 with just bug fixes out there? It might help reduce problems and future bug reports. Or I could back out my most recent changes and we could produce a Sigil-0.9.4 with those bug fixes and the new MetaEditor gui. Please let me know if you think either of these options would be better.

Thanks,

KevinH
KevinH is online now   Reply With Quote
Old 02-21-2016, 09:35 PM   #11
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
Posts: 27,552
Karma: 193191846
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
Quote:
Originally Posted by KevinH View Post
Hi DiapDealer,
Should we push out a Sigil-0.9.3b or Sigil-0.9.3v2 with just bug fixes out there? It might help reduce problems and future bug reports. Or I could back out my most recent changes and we could produce a Sigil-0.9.4 with those bug fixes and the new MetaEditor gui. Please let me know if you think either of these options would be better.

Thanks,

KevinH
I'd say epubs with incorrect package versions and/or missing opf xml declarations are actually pretty rare. I uploaded a new version of the plugin that I think will take care of those instances when they might occur. So unless you're in the mood to do an intermediate release, I say lets hold off.
DiapDealer is offline   Reply With Quote
Old 02-21-2016, 09:46 PM   #12
KevinH
Sigil Developer
KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.
 
Posts: 7,647
Karma: 5433388
Join Date: Nov 2009
Device: many
Hi DiapDealer,

Sounds good to me!
Thanks!

KevinH

Quote:
Originally Posted by DiapDealer View Post
I'd say epubs with incorrect package versions and/or missing opf xml declarations are actually pretty rare. I uploaded a new version of the plugin that I think will take care of those instances when they might occur. So unless you're in the mood to do an intermediate release, I say lets hold off.
KevinH is online now   Reply With Quote
Old 02-22-2016, 02:00 PM   #13
nalor78
Junior Member
nalor78 began at the beginning.
 
Posts: 6
Karma: 10
Join Date: Aug 2010
Location: Austria
Device: Onyx Boox AfterGlow C65ML
Thanks for the analysis and the quick fix!
(and just for the sake of completeness - I've found the calibre plugin and scrambled my book
nalor78 is offline   Reply With Quote
Old 02-22-2016, 02:25 PM   #14
KevinH
Sigil Developer
KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.
 
Posts: 7,647
Karma: 5433388
Join Date: Nov 2009
Device: many
If you copy and rename your epub to end with .zip, unzip your epub and add the xml header declaration to your opf file, and rezip it, and rename it to .epub, you should load into Sigil just fine with nothing changing your package version any longer.

Either that or use DiapDealers new import plugin to load your epub. Once saved, you should not need to worry about using the plugi for that epub in the future as Sigil itlsef adds the required xml declaration heading.

Please let us know if that doesn't do the trick. The real fix will appear in the next release.

KevinH
KevinH is online now   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Comments in content.opf with Sigil 0.9.2 turbulent Sigil 4 02-15-2016 05:29 PM
avoiding Sigil's meta in content.opf sbin Sigil 25 01-08-2016 03:51 PM
Sigil 0.5.3 keeps rebuilding my content.opf file from scratch mtrahan Sigil 7 04-28-2012 09:10 AM
Sigil corrupting content.opf (0.4, 0.5) cyana Sigil 21 02-11-2012 05:25 PM
Sigil resets edits to content.opf adv_dp_fan Sigil 7 09-28-2011 06:50 PM


All times are GMT -4. The time now is 03:45 PM.


MobileRead.com is a privately owned, operated and funded community.