Skip to content

Commit fdabe66

Browse files
committed
feat: check that overlays audio file URLs have no fragments
This is reported as `MED-014` (repurposed). Fixes #1251
1 parent 2091d14 commit fdabe66

File tree

4 files changed

+29
-2
lines changed

4 files changed

+29
-2
lines changed

src/main/java/com/adobe/epubcheck/overlay/OverlayHandler.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import com.adobe.epubcheck.messages.MessageId;
1212
import com.adobe.epubcheck.opf.OPFChecker30;
1313
import com.adobe.epubcheck.opf.ValidationContext;
14-
import com.adobe.epubcheck.opf.XRefChecker;
1514
import com.adobe.epubcheck.opf.XRefChecker.Type;
1615
import com.adobe.epubcheck.util.EpubConstants;
1716
import com.adobe.epubcheck.vocab.AggregateVocab;
@@ -163,8 +162,17 @@ private void processAudioSrc()
163162
{
164163

165164
URL url = checkURL(currentElement().getAttribute("src"));
165+
166+
// check that the URL has no fragment
167+
if (url.fragment() != null)
168+
{
169+
report.message(MessageId.MED_014, location(), url.fragment());
170+
url = URLUtils.docURL(url);
171+
}
172+
166173
if (url != null && context.xrefChecker.isPresent())
167174
{
175+
168176
// check that the audio type is a core media type resource
169177
String mimeType = context.xrefChecker.get().getMimeType(url);
170178
if (mimeType != null && !OPFChecker30.isBlessedAudioType(mimeType))

src/main/resources/com/adobe/epubcheck/messages/MessageBundle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ MED_010=EPUB Content Documents referenced from a Media Overlay must specify the
142142
MED_011=EPUB Content Document referenced from multiple Media Overlay Documents.
143143
MED_012=The "media-overlay" attribute does not match the ID of the Media Overlay that refers to this document.
144144
MED_013=Media Overlay Document referenced from the "media-overlay" attribute does not contain a reference to this Content Document.
145-
MED_014=A non-empty fragment identifier is required.
145+
MED_014=Media overlay audio file URLs must not have a fragment, but found '#%1$s'.
146146
MED_015=Media overlay text references must be in reading order. Text target "%1$s" is before the previous link target in %2$s order.
147147
MED_016=Media Overlays total duration should be the sum of the durations of all Media Overlays documents.
148148
MED_017=URL fragment should indicate an element ID, but found '#%1$s'.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<smil xmlns="http://www.w3.org/ns/SMIL" xmlns:epub="http://www.idpf.org/2007/ops" version="3.0">
3+
<body>
4+
<par id="par1">
5+
<text src="chapter1.xhtml#text1"/>
6+
<audio src="chapter1.mp3" clipBegin="0s" clipEnd="10s"/>
7+
</par>
8+
<par id="par2">
9+
<text src="chapter1.xhtml#text2"/>
10+
<audio src="chapter1.mp3#fragment" clipBegin="10s" clipEnd="20s"/>
11+
</par>
12+
</body>
13+
</smil>

src/test/resources/epub3/09-media-overlays/media-overlays.feature

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,12 @@ Feature: EPUB 3 — Media Overlays
9292

9393
#### 9.2.2.8 The `audio` element
9494

95+
@spec @xref:sec-smil-audio-elem
96+
Scenario: Report an audio file URL with a fragment
97+
When checking document 'audio-src-fragment-error.smil'
98+
Then error MED-014 is reported
99+
And no other errors or warnings are reported
100+
95101
@spec @xref:sec-smil-audio-elem
96102
Scenario: Allow clock values with the full clock syntax (`hh:mm:ss.milli`)
97103
When checking document 'clock-value-full-syntax-valid.smil'

0 commit comments

Comments
 (0)