mirror of
https://github.com/gedoor/legado.git
synced 2024-07-04 23:36:56 +08:00
优化
This commit is contained in:
parent
2f49d09cd0
commit
d8cc932527
|
@ -101,13 +101,6 @@ public class LazyResource extends Resource {
|
|||
throw new IOException(
|
||||
"Could not load the contents of resource: " + this.getHref());
|
||||
} else {
|
||||
/*掌上书苑有很多自制书OPF的nameSpace格式不标准,强制修复成正确的格式*/
|
||||
if (getHref().endsWith("opf")) {
|
||||
String string = new String(readData)
|
||||
.replace(" smlns=\"", " xmlns=\"")
|
||||
.replace(" mlns=\"", " xmlns=\"");
|
||||
readData = string.getBytes();
|
||||
}
|
||||
this.data = readData;
|
||||
}
|
||||
|
||||
|
|
|
@ -48,6 +48,12 @@ public class PackageDocumentReader extends PackageDocumentBase {
|
|||
Resource packageResource, EpubReader epubReader, EpubBook book,
|
||||
Resources resources)
|
||||
throws SAXException, IOException {
|
||||
/*掌上书苑有很多自制书OPF的nameSpace格式不标准,强制修复成正确的格式*/
|
||||
String string = new String(packageResource.getData())
|
||||
.replace(" smlns=\"", " xmlns=\"")
|
||||
.replace(" mlns=\"", " xmlns=\"");
|
||||
packageResource.setData(string.getBytes());
|
||||
|
||||
Document packageDocument = ResourceUtil.getAsDocument(packageResource);
|
||||
String packageHref = packageResource.getHref();
|
||||
resources = fixHrefs(packageHref, resources);
|
||||
|
|
|
@ -75,14 +75,6 @@ public class ResourcesLoader {
|
|||
} else {
|
||||
resource = ResourceUtil
|
||||
.createResource(zipEntry.getName(), zipFileWrapper.getInputStream(zipEntry));
|
||||
/*掌上书苑有很多自制书OPF的nameSpace格式不标准,强制修复成正确的格式*/
|
||||
if (href.endsWith("opf")) {
|
||||
String string = new String(resource.getData())
|
||||
.replace(" smlns=\"", " xmlns=\"")
|
||||
.replace(" mlns=\"", " xmlns=\"");
|
||||
resource.setData(string.getBytes());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (resource.getMediaType() == MediaTypes.XHTML) {
|
||||
|
@ -134,17 +126,10 @@ public class ResourcesLoader {
|
|||
if ((zipEntry == null) || zipEntry.isDirectory()) {
|
||||
continue;
|
||||
}
|
||||
String href = zipEntry.getName();
|
||||
//String href = zipEntry.getName();
|
||||
|
||||
// store resource
|
||||
Resource resource = ResourceUtil.createResource(zipEntry.getName(), zipInputStream);
|
||||
///*掌上书苑有很多自制书OPF的nameSpace格式不标准,强制修复成正确的格式*/
|
||||
if (href.endsWith("opf")) {
|
||||
String string = new String(resource.getData())
|
||||
.replace(" smlns=\"", " xmlns=\"")
|
||||
.replace(" mlns=\"", " xmlns=\"");
|
||||
resource.setData(string.getBytes());
|
||||
}
|
||||
if (resource.getMediaType() == MediaTypes.XHTML) {
|
||||
resource.setInputEncoding(defaultHtmlEncoding);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user