diff --git a/src/main/java/com/adobe/epubcheck/opf/XRefChecker.java b/src/main/java/com/adobe/epubcheck/opf/XRefChecker.java index 038d3028e..5214e9c6b 100755 --- a/src/main/java/com/adobe/epubcheck/opf/XRefChecker.java +++ b/src/main/java/com/adobe/epubcheck/opf/XRefChecker.java @@ -60,7 +60,7 @@ public static enum Type private static class Reference { - public final String resource; + public final String source; public final int lineNumber; public final int columnNumber; public final String refResource; @@ -70,11 +70,11 @@ private static class Reference public Reference(String srcResource, int srcLineNumber, int srcColumnNumber, String refResource, String fragment, Type type) { - this.fragment = fragment; + this.source = srcResource; this.lineNumber = srcLineNumber; this.columnNumber = srcColumnNumber; this.refResource = refResource; - this.resource = srcResource; + this.fragment = fragment; this.type = type; } @@ -238,7 +238,7 @@ public void checkReferences() private void checkReference(Reference ref) { Resource res = resources.get(ref.refResource); - Resource host = resources.get(ref.resource); + Resource host = resources.get(ref.source); // Check undeclared resources if (res == null) @@ -252,7 +252,7 @@ private void checkReference(Reference ref) else { report.message(MessageId.RSC_007w, - EPUBLocation.create(ref.resource, ref.lineNumber, ref.columnNumber, ref.refResource), + EPUBLocation.create(ref.source, ref.lineNumber, ref.columnNumber, ref.refResource), ref.refResource); } } @@ -260,12 +260,12 @@ else if (ref.refResource.matches("^[^:/?#]+://.*") && !(version == EPUBVersion.V && (ref.type == Type.AUDIO || ref.type == Type.VIDEO))) { report.message(MessageId.RSC_006, - EPUBLocation.create(ref.resource, ref.lineNumber, ref.columnNumber, ref.refResource)); + EPUBLocation.create(ref.source, ref.lineNumber, ref.columnNumber, ref.refResource)); } else if (!ocf.hasEntry(ref.refResource) && !ref.refResource.matches("^[^:/?#]+://.*")) { report.message(MessageId.RSC_007, - EPUBLocation.create(ref.resource, ref.lineNumber, ref.columnNumber, ref.refResource), + EPUBLocation.create(ref.source, ref.lineNumber, ref.columnNumber, ref.refResource), ref.refResource); } @@ -273,7 +273,8 @@ else if (!undeclared.contains(ref.refResource)) { undeclared.add(ref.refResource); report.message(MessageId.RSC_008, - EPUBLocation.create(ref.resource, ref.lineNumber, ref.columnNumber, ref.refResource)); + EPUBLocation.create(ref.source, ref.lineNumber, ref.columnNumber, ref.refResource), + ref.refResource); } return; } @@ -288,20 +289,20 @@ else if (!undeclared.contains(ref.refResource)) && !res.hasValidItemFallback) { report.message(MessageId.RSC_010, - EPUBLocation.create(ref.resource, ref.lineNumber, ref.columnNumber, + EPUBLocation.create(ref.source, ref.lineNumber, ref.columnNumber, ref.refResource + ((ref.fragment != null) ? '#' + ref.fragment : ""))); } if (/* !res.mimeType.equals("font/opentype") && */!res.item.isInSpine()) { report.message(MessageId.RSC_011, - EPUBLocation.create(ref.resource, ref.lineNumber, ref.columnNumber, + EPUBLocation.create(ref.source, ref.lineNumber, ref.columnNumber, ref.refResource + ((ref.fragment != null) ? '#' + ref.fragment : ""))); } break; case IMAGE: if (ref.fragment != null) { - report.message(MessageId.RSC_009, EPUBLocation.create(ref.resource, ref.lineNumber, + report.message(MessageId.RSC_009, EPUBLocation.create(ref.source, ref.lineNumber, ref.columnNumber, ref.refResource + "#" + ref.fragment)); return; } @@ -309,7 +310,7 @@ else if (!undeclared.contains(ref.refResource)) if (!OPFChecker.isBlessedImageType(res.item.getMimeType()) && !res.hasValidImageFallback) { report.message(MessageId.MED_003, - EPUBLocation.create(ref.resource, ref.lineNumber, ref.columnNumber), + EPUBLocation.create(ref.source, ref.lineNumber, ref.columnNumber), res.item.getMimeType()); } break; @@ -317,7 +318,7 @@ else if (!undeclared.contains(ref.refResource)) if (!res.item.isFixedLayout()) { report.message(MessageId.NAV_009, - EPUBLocation.create(ref.resource, ref.lineNumber, ref.columnNumber)); + EPUBLocation.create(ref.source, ref.lineNumber, ref.columnNumber)); } return; case SEARCH_KEY: @@ -325,13 +326,13 @@ else if (!undeclared.contains(ref.refResource)) if ((ref.fragment == null || !ref.fragment.startsWith("epubcfi(")) && !res.item.isInSpine()) { report.message(MessageId.RSC_021, - EPUBLocation.create(ref.resource, ref.lineNumber, ref.columnNumber), ref.refResource); + EPUBLocation.create(ref.source, ref.lineNumber, ref.columnNumber), ref.refResource); } break; case STYLESHEET: if (ref.fragment != null) { - report.message(MessageId.RSC_013, EPUBLocation.create(ref.resource, ref.lineNumber, + report.message(MessageId.RSC_013, EPUBLocation.create(ref.source, ref.lineNumber, ref.columnNumber, ref.refResource + "#" + ref.fragment)); return; } @@ -356,7 +357,7 @@ else if (!undeclared.contains(ref.refResource)) if (ref.fragment == null) { report.message(MessageId.RSC_015, - EPUBLocation.create(ref.resource, ref.lineNumber, ref.columnNumber, ref.refResource)); + EPUBLocation.create(ref.source, ref.lineNumber, ref.columnNumber, ref.refResource)); return; } break; @@ -386,7 +387,7 @@ else if (ref.fragment.contains("=") && host != null && host.item.getProperties() Anchor anchor = res.anchors.get(ref.fragment); if (anchor == null) { - report.message(MessageId.RSC_012, EPUBLocation.create(ref.resource, ref.lineNumber, + report.message(MessageId.RSC_012, EPUBLocation.create(ref.source, ref.lineNumber, ref.columnNumber, ref.refResource + "#" + ref.fragment)); return; } @@ -396,7 +397,7 @@ else if (ref.fragment.contains("=") && host != null && host.item.getProperties() case SVG_CLIP_PATH: if (anchor.type != ref.type) { - report.message(MessageId.RSC_014, EPUBLocation.create(ref.resource, ref.lineNumber, + report.message(MessageId.RSC_014, EPUBLocation.create(ref.source, ref.lineNumber, ref.columnNumber, ref.refResource + "#" + ref.fragment)); } break; @@ -404,7 +405,7 @@ else if (ref.fragment.contains("=") && host != null && host.item.getProperties() case HYPERLINK: if (anchor.type != ref.type && anchor.type != Type.GENERIC) { - report.message(MessageId.RSC_014, EPUBLocation.create(ref.resource, ref.lineNumber, + report.message(MessageId.RSC_014, EPUBLocation.create(ref.source, ref.lineNumber, ref.columnNumber, ref.refResource + "#" + ref.fragment)); } break; diff --git a/src/main/resources/com/adobe/epubcheck/messages/MessageBundle.properties b/src/main/resources/com/adobe/epubcheck/messages/MessageBundle.properties index e3bc2b285..d42cb9606 100644 --- a/src/main/resources/com/adobe/epubcheck/messages/MessageBundle.properties +++ b/src/main/resources/com/adobe/epubcheck/messages/MessageBundle.properties @@ -278,7 +278,7 @@ RSC_006=Remote resource reference not allowed; resource must be placed in the OC RSC_006_SUG=Only audio and video remote resources are permitted. RSC_007=Referenced resource '%1$s' could not be found in the EPUB. RSC_007w=Referenced resource '%1$s' could not be found in the EPUB. -RSC_008=Referenced resource is not declared in the OPF manifest. +RSC_008=Referenced resource '%1$s' is not declared in the OPF manifest. RSC_009=A fragment identifier should not be used with an img src attribute. RSC_010=Reference to non-standard resource type found. RSC_011=Found a reference to a resource that is not a spine item. diff --git a/src/test/resources/com/adobe/epubcheck/test/command_line/listSeverities_expected_results.txt b/src/test/resources/com/adobe/epubcheck/test/command_line/listSeverities_expected_results.txt index 4273034c9..e3915b5e7 100644 --- a/src/test/resources/com/adobe/epubcheck/test/command_line/listSeverities_expected_results.txt +++ b/src/test/resources/com/adobe/epubcheck/test/command_line/listSeverities_expected_results.txt @@ -197,7 +197,7 @@ RSC-004 ERROR File '%1$s' could not be decrypted. RSC-005 ERROR Error while parsing file '%1$s'. RSC-006 ERROR Remote resource reference not allowed; resource must be placed in the OCF. Only audio and video remote resources are permitted. RSC-007 ERROR Referenced resource '%1$s' could not be found in the EPUB. -RSC-008 ERROR Referenced resource is not declared in the OPF manifest. +RSC-008 ERROR Referenced resource '%1$s' is not declared in the OPF manifest. RSC-009 ERROR A fragment identifier should not be used with an img src attribute. RSC-010 ERROR Reference to non-standard resource type found. RSC-011 WARNING Found a reference to a resource that is not a spine item.