Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Formats > Kindle Formats

Notices

Reply
 
Thread Tools Search this Thread
Old 08-22-2014, 06:03 PM   #946
poxalew
Junior Member
poxalew began at the beginning.
 
Posts: 1
Karma: 10
Join Date: Aug 2014
Device: Kindle PW2
Exclamation Watermark header bug

Hi there!
First of all, thanks for the wonderful tool!

Found a bug in mobi_header.py, namely: The contents of header 208 (watermark) is dumped as a string into the generated .opf. Since under certain circumstances it can contain code points outside of the range allowable in XML, in those cases the resulting .opf becomes invalid.

The fix is very simple--it just involves moving 208 from id_map_strings to id_map_hexstrings. Sample patch against 0.73 below.

Code:
--- mobi_header.py.orig 2014-07-14 18:32:44.000000000 +0300
+++ mobi_header.py      2014-08-23 00:50:43.312531211 +0300
@@ -71,7 +71,6 @@
         129 : 'K8_Masthead/Cover_Image_(129)',
         132 : 'RegionMagnification_(132)',
         200 : 'DictShortName_(200)',
-        208 : 'Watermark_(208)',
         501 : 'cdeType_(501)',
         502 : 'last_update_time_(502)',
         503 : 'Updated_Title_(503)',
@@ -113,6 +112,7 @@
         404 : 'Text_to_Speech_Disabled_(404)',
     }
     id_map_hexstrings = {
+        208 : 'Watermark_(208_in_hex)',
         209 : 'Tamper_Proof_Keys_(209_in_hex)',
         300 : 'Font_Signature_(300_in_hex)',
     }
@@ -370,7 +370,6 @@
         129 : 'K8(129)_Masthead/Cover_Image',
         132 : 'RegionMagnification',
         200 : 'DictShortName',
-        208 : 'Watermark',
         501 : 'cdeType',
         502 : 'last_update_time',
         503 : 'Updated_Title',
@@ -412,6 +411,7 @@
         406 : 'Rental_Indicator',
     }
     id_map_hexstrings = {
+        208 : 'Watermark (hex)',
         209 : 'Tamper Proof Keys (hex)',
         300 : 'Font Signature (hex)',
         403 : 'Unknown_(403) (hex)',

Last edited by poxalew; 08-22-2014 at 06:13 PM. Reason: Clarified that the patch is against v0.73
poxalew is offline   Reply With Quote
Old 08-23-2014, 12:38 PM   #947
KevinH
Guru
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: 836
Karma: 349410
Join Date: Nov 2009
Device: many
Hi poxalew,

Your patch makes good sense. I will include it in the next official release.

Thanks!

KevinH
KevinH is offline   Reply With Quote
Old 08-26-2014, 04:29 PM   #948
KevinH
Guru
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: 836
Karma: 349410
Join Date: Nov 2009
Device: many
Hi lglgaigogo,

I really am not good at the dictionary stuff at all. I am not its original author. I did however make a change to mobi_dict.py to try and capture and read the ORDT table info. And although I really have no idea what the markup for dictionaries is supposed to look like, the idxrth info now looks like it is deciphering properly.

Will you please download the attached mobi_dict.py.zip, unzip it and use it to replace its namesake in KindleUnpack_v073/lib/.

Then try and unpack your dictionary and see if you can see any improvement and let me know what else if anything remains to be fixed.

Thanks,

KevinH

Quote:
Originally Posted by lglgaigogo View Post
Thank you for paying attention on my issue. I am now try to understand the non western character encoding pattern.
Thank you.

For now, I figure out:

1.Every character has 2 bytes index
2.For western letters it should be like 00 XX ,for example, 'a' is 00 03, 'b' is 00 64, and look up the table ORDT:
ORDT[3*2+1] is 'a'
ORDT[64*2+1] is 'b'
3.For non western letters, it should be like XX XX, for example, '潘' is 6F 58, and in python:
Code:
 print u"\u6F58" # is exactly the character '潘'
Attached Files
File Type: zip mobi_dict.py.zip (3.4 KB, 2 views)
KevinH is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Can i rotate text and insert images in Mobi and EPUB? JanGLi Kindle Formats 5 02-02-2013 04:16 PM
PDF to Mobi with text and images pocketsprocket Kindle Formats 7 05-21-2012 07:06 AM
Mobi files - images DWC Introduce Yourself 5 07-06-2011 01:43 AM
pdf to mobi... creating images rather than text Dumhed Calibre 5 11-06-2010 12:08 PM
Transfer of images on text files anirudh215 PDF 2 06-22-2009 09:28 AM


All times are GMT -4. The time now is 03:09 AM.


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