Skip to content
This repository has been archived by the owner on Nov 22, 2022. It is now read-only.

Spaces in TARGETDURATION and MEDIA-SEQUENCE tags #28

Open
ketankhairnar opened this issue Dec 23, 2015 · 3 comments
Open

Spaces in TARGETDURATION and MEDIA-SEQUENCE tags #28

ketankhairnar opened this issue Dec 23, 2015 · 3 comments

Comments

@ketankhairnar
Copy link
Contributor

I've observed spaces in generated m3u8 from CDNs for these tags. Note the space after colon. Do we need to handle this as part of library? Spec doesn't say whether space is allowed.

should be #EXT-X-TARGETDURATION:<s>  but seen as #EXT-X-TARGETDURATION: <s>
should be #EXT-X-MEDIA-SEQUENCE:<number> but seen as #EXT-X-MEDIA-SEQUENCE: <number>

For now I've handled with below change in Constants.java.

public static final Pattern EXT_X_TARGETDURATION_PATTERN = Pattern.compile("^#" + EXT_X_TARGETDURATION_TAG + EXT_TAG_END + OPTIONAL_WHITESPACE_REGEX +"(" + INTEGER_REGEX + ")"+OPTIONAL_WHITESPACE_REGEX+"$");
public static final Pattern EXT_X_MEDIA_SEQUENCE_PATTERN = Pattern.compile("^#" + EXT_X_MEDIA_SEQUENCE_TAG + EXT_TAG_END + OPTIONAL_WHITESPACE_REGEX +"(" + INTEGER_REGEX + ")"+OPTIONAL_WHITESPACE_REGEX+"$");

Where regex for optional white space is as below

private static final String OPTIONAL_WHITESPACE_REGEX = "\\s*?";

Let me know if this makes sense. There is no harm if no spaces exist. regex takes care of that case too.

@Wopple
Copy link
Contributor

Wopple commented Dec 23, 2015

The regexes look good. I would add an allowWhitespaceInTags flag in ParsingMode and set it to true for the LENIENT constant. At this point I'm considering making LENIENT the default.

@ketankhairnar
Copy link
Contributor Author

While default LENIENT mode seems easy option with allowWhitespaceInTags set to true; Am wondering when would need STRICT parsing mode.

Let me know when can this be added? you need any PR for this?

@derjust
Copy link
Contributor

derjust commented Sep 15, 2016

You would need strict for non-forgiving M3u8 consumers (So far I haven't seen any - usually they are all very forgiving)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants