From e1871e26ed9485b48a3d9b0681205ffd7bad6ea1 Mon Sep 17 00:00:00 2001 From: Romain Deltour Date: Sun, 22 Dec 2024 02:16:33 +0100 Subject: [PATCH] fix: prevent some internal URLs from leaking in messages Fix #1542 --- src/main/java/com/adobe/epubcheck/opf/OPFChecker.java | 7 +++---- src/main/java/com/adobe/epubcheck/opf/OPFChecker30.java | 6 ++---- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/adobe/epubcheck/opf/OPFChecker.java b/src/main/java/com/adobe/epubcheck/opf/OPFChecker.java index caef644be..7c16db8aa 100755 --- a/src/main/java/com/adobe/epubcheck/opf/OPFChecker.java +++ b/src/main/java/com/adobe/epubcheck/opf/OPFChecker.java @@ -163,19 +163,18 @@ protected void checkGuide() Optional item = opfHandler.getItemByURL(ref.getDocumentURL()); if (!item.isPresent()) { - // FIXME 2022 check how to report URL report.message(MessageId.OPF_031, - EPUBLocation.of(context).at(ref.getLineNumber(), ref.getColumnNumber()), ref.getURL()); + EPUBLocation.of(context).at(ref.getLineNumber(), ref.getColumnNumber()), + context.relativize(ref.getURL())); } else { if (!isBlessedItemType(item.get().getMimeType(), version) && !isDeprecatedBlessedItemType(item.get().getMimeType())) { - // FIXME 2022 check how to report URL report.message(MessageId.OPF_032, EPUBLocation.of(context).at(ref.getLineNumber(), ref.getColumnNumber()), - ref.getURL()); + context.relativize(ref.getURL())); } } } diff --git a/src/main/java/com/adobe/epubcheck/opf/OPFChecker30.java b/src/main/java/com/adobe/epubcheck/opf/OPFChecker30.java index 0338efa64..626b2beee 100644 --- a/src/main/java/com/adobe/epubcheck/opf/OPFChecker30.java +++ b/src/main/java/com/adobe/epubcheck/opf/OPFChecker30.java @@ -302,9 +302,8 @@ private void checkDictCollection(ResourceCollection collection) Optional item = opfHandler.getItemByURL(resource.getDocumentURL()); if (!item.isPresent()) { - // FIXME 2022 check how to report the URL report.message(MessageId.OPF_081, EPUBLocation.of(context), - resource.getDocumentURL().path()); + context.relativize(resource.getDocumentURL())); } else if ("application/vnd.epub.search-key-map+xml".equals(item.get().getMimeType())) { @@ -317,9 +316,8 @@ else if ("application/vnd.epub.search-key-map+xml".equals(item.get().getMimeType } else if (!"application/xhtml+xml".equals(item.get().getMimeType())) { - // FIXME 2022 check how to report the URL report.message(MessageId.OPF_084, EPUBLocation.of(context), - resource.getDocumentURL().path()); + context.relativize(resource.getDocumentURL())); } } if (!skmFound)