video-dev / hls.js

HLS.js is a JavaScript library that plays HLS in browsers with support for MSE.

Home Page:https://hlsjs.video-dev.org/demo

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

HLS fails to stream video with name containing U+3000 character.

teecj98 opened this issue · comments

What version of Hls.js are you using?

1.4.9

What browser (including version) are you using?

Chrome

What OS (including version) are you using?

Windows 10

Test stream

No response

Configuration

{
  xhrSetup: function (xhr) {
   xhr.withCredentials = true;
 }
}

Additional player setup steps

No response

Checklist

Steps to reproduce

[ I paste the m3u8 content here as .m3u8 file is not allowed to be uploaded here]
[m3u8 1]
#EXTM3U
#EXT-X-VERSION:3
#EXT-X-MEDIA-SEQUENCE:0
#EXT-X-ALLOW-CACHE:YES
#EXT-X-TARGETDURATION:13
#EXTINF:12.133333,
sample-mp4-file_240p_00000.ts
#EXTINF:12.000000,
sample-mp4-file_240p_00001.ts
#EXTINF:6.000000,
sample-mp4-file_240p_00002.ts
#EXTINF:12.000000,
sample-mp4-file_240p_00003.ts
#EXTINF:12.000000,
sample-mp4-file_240p_00004.ts
#EXTINF:6.000000,
sample-mp4-file_240p_00005.ts
#EXTINF:12.000000,
sample-mp4-file_240p_00006.ts
#EXTINF:12.000000,
sample-mp4-file_240p_00007.ts
#EXTINF:6.000000,
sample-mp4-file_240p_00008.ts
#EXTINF:12.000000,
sample-mp4-file_240p_00009.ts
#EXTINF:12.000000,
sample-mp4-file_240p_00010.ts
#EXTINF:6.000000,
sample-mp4-file_240p_00011.ts
#EXTINF:5.933333,
sample-mp4-file_240p_00012.ts
#EXT-X-ENDLIST

[m3u8 2]
#EXTM3U
#EXT-X-VERSION:3
#EXT-X-MEDIA-SEQUENCE:0
#EXT-X-ALLOW-CACHE:YES
#EXT-X-TARGETDURATION:13
#EXTINF:12.133333,
sample-mp4-file _240p_00000.ts
#EXTINF:12.000000,
sample-mp4-file _240p_00001.ts
#EXTINF:6.000000,
sample-mp4-file _240p_00002.ts
#EXTINF:12.000000,
sample-mp4-file _240p_00003.ts
#EXTINF:12.000000,
sample-mp4-file _240p_00004.ts
#EXTINF:6.000000,
sample-mp4-file _240p_00005.ts
#EXTINF:12.000000,
sample-mp4-file _240p_00006.ts
#EXTINF:12.000000,
sample-mp4-file _240p_00007.ts
#EXTINF:6.000000,
sample-mp4-file _240p_00008.ts
#EXTINF:12.000000,
sample-mp4-file _240p_00009.ts
#EXTINF:12.000000,
sample-mp4-file _240p_00010.ts
#EXTINF:6.000000,
sample-mp4-file _240p_00011.ts
#EXTINF:5.933333,
sample-mp4-file _240p_00012.ts
#EXT-X-ENDLIST

  1. Observe the difference between the ts files in each m3u8 file
  • there is " " character (u+3000) in the [m3u8 2] and no space in the [m3u8 1]
  1. Upload the files to a file hosting e.g. https://tmpfiles.org/
  2. Paste the url in https://hlsjs.video-dev.org/demo/ or https://hlsjs-dev.video-dev.org/demo/
  3. Open the network tab.
  4. Observe and compare the ts file names it attempts to download and the ts file names listed in the m3u8 file itself
  5. for [m3u8 1], the ts files to download are the same as those listed in the m3u8 file
  6. for [m3u8 2], the ts files to download are different from those listed in the m3u8 files

Expected behaviour

  1. for [m3u8 1], the ts files to download are the same as those listed in the m3u8 file
  2. for [m3u8 2], the ts files to download are also the same from those listed in the m3u8 files

What actually happened?

Compare the ts file names in the m3u8 content and the files attempted to download. The u+3000 character caused it to get the wrong ts name.

Note: please ignore the 404 as I didnt upload the real ts files. The issue is the name of the ts files to download.

for [m3u8 1], the ts files to download are the same as those listed in the m3u8 file
image

for [m3u8 2], the ts files to download are different from those listed in the m3u8 files
image

Console output

NA

Chrome media internals output

No response

The issue is that the m3u8-parser's RegEx for #EXTINF urls does not match whitespace characters other than space (to avoid newline):

/(?!#) *(\S[\S ]*)/.source, // segment URI, group 3 => the URI (note newline is not eaten)

An appropriate fix would be to update the RegEx to match everything up to the first return or new line:
/(?!#) *(\S[^\r\n]*)/

Using[^\r\n]* would match the pattern used for multivariant playlist URLs.

Can you file a PR with a fix?

Hi @teecj98,

I've posted a fix in #6396 which is schedule for release in v1.6.0.