GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat: improve checking of data URLs · w3c/epubcheck@cbc0b2a

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • src
    • main
      • java
        • com/adobe/epubcheck
          • messages
            • DefaultSeverities.java
            • MessageId.java
          • ocf
            • OCFContainer.java
          • opf
            • OPFChecker.java
            • OPFChecker30.java
            • OPFItem.java
            • ValidationContext.java
            • XRefChecker.java
          • ops
            • OPSHandler.java
            • OPSHandler30.java
          • xml/handlers
            • BaseURLHandler.java
        • org/w3c/epubcheck/url
          • URLUtils.java
      • resources/com/adobe/epubcheck/messages
        • MessageBundle.properties
    • test/resources/epub3
      • 00-minimal
        • minimal.feature
      • 03-resources
        • files
          • data-url-in-html-a-href-error.xhtml
          • data-url-in-html-area-href-error.xhtml
          • data-url-in-html-img-cmt-valid
            • EPUB
              • content_001.xhtml
              • nav.xhtml
              • package.opf
            • META-INF
              • container.xml
            • mimetype
          • data-url-in-html-img-foreign-intrinsic-fallback-valid
            • EPUB
              • content_001.xhtml
              • image.jpeg
              • nav.xhtml
              • package.opf
            • META-INF
              • container.xml
            • mimetype
          • data-url-in-html-img-foreign-manifest-fallback-valid
            • EPUB
              • content_001.xhtml
              • image.jpeg
              • nav.xhtml
              • package.opf
            • META-INF
              • container.xml
            • mimetype
          • data-url-in-html-img-foreign-no-fallback-error
            • EPUB
              • content_001.xhtml
              • nav.xhtml
              • package.opf
            • META-INF
              • container.xml
            • mimetype
          • data-url-in-html-link-exempt-valid
            • EPUB
              • content_001.xhtml
              • nav.xhtml
              • package.opf
            • META-INF
              • container.xml
            • mimetype
          • data-url-in-manifest-item-in-spine-error.opf
          • data-url-in-manifest-item-valid.opf
          • data-url-in-svg-a-href-error.xhtml
        • resources.feature

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Dismiss banner
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/main/java/com/adobe/epubcheck/messages/DefaultSeverities.java‎

Copy file name to clipboardExpand all lines: src/main/java/com/adobe/epubcheck/messages/DefaultSeverities.java
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,7 @@ private void initialize()
340340
severities.put(MessageId.RSC_026, Severity.ERROR);
341341
severities.put(MessageId.RSC_027, Severity.WARNING);
342342
severities.put(MessageId.RSC_028, Severity.ERROR);
343+
severities.put(MessageId.RSC_029, Severity.ERROR);
343344

344345
// Scripting
345346
severities.put(MessageId.SCP_001, Severity.SUPPRESSED); // checking scripts is out of scope
Collapse file

‎src/main/java/com/adobe/epubcheck/messages/MessageId.java‎

Copy file name to clipboardExpand all lines: src/main/java/com/adobe/epubcheck/messages/MessageId.java
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,7 @@ public enum MessageId implements Comparable<MessageId>
334334
RSC_026("RSC-026"),
335335
RSC_027("RSC-027"),
336336
RSC_028("RSC-028"),
337+
RSC_029("RSC-029"),
337338

338339
// Messages relating to scripting
339340
SCP_001("SCP-001"),
Collapse file

‎src/main/java/com/adobe/epubcheck/ocf/OCFContainer.java‎

Copy file name to clipboardExpand all lines: src/main/java/com/adobe/epubcheck/ocf/OCFContainer.java
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,9 @@ public boolean isRemote(URL url)
130130
}
131131
else
132132
{
133-
return !(URLUtils.isSameOrigin(url, rootURL));
133+
return URLUtils.isRemote(url, rootURL);
134134
}
135135
}
136136

137+
137138
}
Collapse file

‎src/main/java/com/adobe/epubcheck/opf/OPFChecker.java‎

Copy file name to clipboardExpand all lines: src/main/java/com/adobe/epubcheck/opf/OPFChecker.java
+5-1Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ protected boolean checkContent()
210210
// only check the filename in single-file mode
211211
// (it is checked by the container checker in full-publication mode)
212212
// and for local resources (i.e. computed to a file URL)
213-
if (!context.container.isPresent() && !item.isRemote())
213+
if (!context.container.isPresent() && !item.isRemote() && !item.hasDataURL())
214214
{
215215
new OCFFilenameChecker(item.getPath(), context, item.getLocation()).check();
216216
}
@@ -378,6 +378,10 @@ else if (isBlessedStyleType(mimeType))
378378

379379
protected void checkItemContent(OPFItem item)
380380
{
381+
// We do not currently support checking resources defined as data URLs
382+
if (item.hasDataURL()) {
383+
return;
384+
}
381385
// Create a new validation context for the OPF item
382386
// FIXME 2022 set context OPFItem here
383387
// (instead of from XRefChecker in the builder code)
Collapse file

‎src/main/java/com/adobe/epubcheck/opf/OPFChecker30.java‎

Copy file name to clipboardExpand all lines: src/main/java/com/adobe/epubcheck/opf/OPFChecker30.java
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,12 @@ else if (!overlayTextChecker.isCorrectOverlay(docURL, mo))
186186
@Override
187187
protected void checkSpineItem(OPFItem item, OPFHandler opfHandler)
188188
{
189+
// Items with `data:` URLs are not allowed in the spine
190+
if (item.hasDataURL()) {
191+
report.message(MessageId.RSC_029, item.getLocation());
192+
return;
193+
}
194+
189195
String mimeType = item.getMimeType();
190196

191197
if (item.getProperties()
Collapse file

‎src/main/java/com/adobe/epubcheck/opf/OPFItem.java‎

Copy file name to clipboardExpand all lines: src/main/java/com/adobe/epubcheck/opf/OPFItem.java
+17Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,13 @@ private OPFItem(Builder builder)
109109
{
110110
this.path = url.toHumanString();
111111
}
112+
// If the item is defined with a data URL, return
113+
// the URL string truncated arbitrarily to 30 chars
114+
else if ("data".equals(url.scheme()))
115+
{
116+
String urlString = url.toString();
117+
this.path = url.toString().substring(0, Math.min(urlString.length(), 30)) + "…";
118+
}
112119
// If a container is present (full-publication check)
113120
// the item path is relative to the root of the container
114121
else if (builder.container.isPresent())
@@ -289,6 +296,16 @@ public boolean isFixedLayout()
289296
return fixedLayout;
290297
}
291298

299+
/**
300+
* Returns <code>true</code> iff this item is a remote resource.
301+
*
302+
* @return <code>true</code> iff this item is a remote resource.
303+
*/
304+
public boolean hasDataURL()
305+
{
306+
return "data".equals(url.scheme());
307+
}
308+
292309
/**
293310
* Returns <code>true</code> iff this item is a remote resource.
294311
*
Collapse file

‎src/main/java/com/adobe/epubcheck/opf/ValidationContext.java‎

Copy file name to clipboardExpand all lines: src/main/java/com/adobe/epubcheck/opf/ValidationContext.java
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ private String computePath()
141141
{
142142
if (container.isPresent() && !container.get().isRemote(url))
143143
{
144-
if (!url.path().isEmpty())
144+
if (url.path() != null && !url.path().isEmpty())
145145
{
146146
return url.path().substring(1);
147147
}
@@ -181,7 +181,7 @@ public boolean isRemote(URL url)
181181
}
182182
else
183183
{
184-
return !(URLUtils.isSameOrigin(url, this.url));
184+
return URLUtils.isRemote(url, this.url);
185185
}
186186
}
187187

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.