This commit is contained in:
Horis 2023-12-08 22:15:00 +08:00
parent 2f49d09cd0
commit d8cc932527
3 changed files with 7 additions and 23 deletions

View File

@ -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;
}

View File

@ -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);

View File

@ -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);
}