Skip to content

Commit

Permalink
feat: check that overlays audio file URLs have no fragments
Browse files Browse the repository at this point in the history
This is reported as `MED-014` (repurposed).

Fixes #1251
  • Loading branch information
rdeltour committed Nov 27, 2022
1 parent 2091d14 commit fdabe66
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 2 deletions.
10 changes: 9 additions & 1 deletion src/main/java/com/adobe/epubcheck/overlay/OverlayHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import com.adobe.epubcheck.messages.MessageId;
import com.adobe.epubcheck.opf.OPFChecker30;
import com.adobe.epubcheck.opf.ValidationContext;
import com.adobe.epubcheck.opf.XRefChecker;
import com.adobe.epubcheck.opf.XRefChecker.Type;
import com.adobe.epubcheck.util.EpubConstants;
import com.adobe.epubcheck.vocab.AggregateVocab;
Expand Down Expand Up @@ -163,8 +162,17 @@ private void processAudioSrc()
{

URL url = checkURL(currentElement().getAttribute("src"));

// check that the URL has no fragment
if (url.fragment() != null)
{
report.message(MessageId.MED_014, location(), url.fragment());
url = URLUtils.docURL(url);
}

if (url != null && context.xrefChecker.isPresent())
{

// check that the audio type is a core media type resource
String mimeType = context.xrefChecker.get().getMimeType(url);
if (mimeType != null && !OPFChecker30.isBlessedAudioType(mimeType))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ MED_010=EPUB Content Documents referenced from a Media Overlay must specify the
MED_011=EPUB Content Document referenced from multiple Media Overlay Documents.
MED_012=The "media-overlay" attribute does not match the ID of the Media Overlay that refers to this document.
MED_013=Media Overlay Document referenced from the "media-overlay" attribute does not contain a reference to this Content Document.
MED_014=A non-empty fragment identifier is required.
MED_014=Media overlay audio file URLs must not have a fragment, but found '#%1$s'.
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.
MED_016=Media Overlays total duration should be the sum of the durations of all Media Overlays documents.
MED_017=URL fragment should indicate an element ID, but found '#%1$s'.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<smil xmlns="http://www.w3.org/ns/SMIL" xmlns:epub="http://www.idpf.org/2007/ops" version="3.0">
<body>
<par id="par1">
<text src="chapter1.xhtml#text1"/>
<audio src="chapter1.mp3" clipBegin="0s" clipEnd="10s"/>
</par>
<par id="par2">
<text src="chapter1.xhtml#text2"/>
<audio src="chapter1.mp3#fragment" clipBegin="10s" clipEnd="20s"/>
</par>
</body>
</smil>
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,12 @@ Feature: EPUB 3 — Media Overlays

#### 9.2.2.8 The `audio` element

@spec @xref:sec-smil-audio-elem
Scenario: Report an audio file URL with a fragment
When checking document 'audio-src-fragment-error.smil'
Then error MED-014 is reported
And no other errors or warnings are reported

@spec @xref:sec-smil-audio-elem
Scenario: Allow clock values with the full clock syntax (`hh:mm:ss.milli`)
When checking document 'clock-value-full-syntax-valid.smil'
Expand Down

0 comments on commit fdabe66

Please sign in to comment.