Comments (6)
The hard part about this is figuring out a consistent and concise way to read and patch the zlib strings.
from kobopatch.
So far, I have this: https://gist.github.com/geek1011/55ca3c4e750aa1bcd497cf296ceb8cf0 , which works for extracting the css. The biggest issue is that when recompressing it, the go zlib library uses a different dict (0x8c instead of 0x8d). Once I can get it to use the proper dict, I'll be able to add it to kobopatch and implement find_zlib, replace_zlib and replace_css instructions.
from kobopatch.
Some notes I've made for myself:
kobo : 1111000 10011100 10001101 10010100 1011111 1101111
78 9c 8d 94 5f 6f
czlib (go): 1111000 10011100 10001100 10010100 1011111 1101111
78 9c 8c 94 5f 6f
go stdlib is completely wrong, so I'm using the czlib library instead.
CMF---- FLG----- DICTID --------------------------
CMF:
- Deflate compression
FLG:
- Uses FDICT
- Default compression (level 6)
DICTID:
- TODO: figure out what the dictionary is (inconsistent between czlib and kobo).
if it comes to it, I might just fork out to python, which uses the correct dict
References:
- https://stackoverflow.com/questions/9050260/what-does-a-zlib-header-look-like
- https://tools.ietf.org/html/rfc1950
from kobopatch.
I think I might just end up embedding (if I can get it to cross-compile to a static binary or exec
ing python (at least for now). Figuring out the compression issue is getting to be a bit too much work. The other alternative might be to use cgo to run a c program which calls zlib.
from kobopatch.
Nevermind, 😠 I missed something obvious again (just like path chars in kepubify)!
Internally, python uses zlib.compressobj
for zlib.compress
. This uses deflateInit2
. When I used czlib, I used czlib.NewWriterLevel
, which internally uses deflateInit
, which is different. To fix this, all I had to do was call czlib.Compress
instead.
Now, I just need to do some more testing, then this feature should be ready!
from kobopatch.
New gist: https://gist.github.com/geek1011/ac32378471be5c0334cff09567fcd057
from kobopatch.
Related Issues (20)
- Add possibility to include other "package" in KoboRoot.tgz HOT 1
- Allow copying files to more than one location in KoboRoot.tgz
- kobopatch.yaml overrides with user-provided strings HOT 1
- ReplaceBLX instruction
- Refactor unit tests
- BLX validation when testing patches
- Refactor kobopatch parsing
- Switch to go modules
- Improve error messages
- Support more than one PatchGroup per patch
- Add note about using spaces for indentation to parsing error
- Log checksums for patched files
- Command to convert the Enabled instruction to kobopatch.yaml overrides
- Built-in firmware download
- Off-by-one symbol offsets
- Add more symbol resolution options HOT 2
- Improve CSS patching heuristics
- [Feature Request] Support add folders from kobopatch.yaml
- Show message box for errors on Windows
- Custom header/footer captions font-family not applied to Custom header/footer page number text
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from kobopatch.