Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
5 tasks done
teecj98 opened this issue Apr 26, 2024 · 2 comments · Fixed by #6396
Closed
5 tasks done

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

teecj98 opened this issue Apr 26, 2024 · 2 comments · Fixed by #6396
Labels
Bug Confirmed Verify Fixed An unreleased bug fix has been merged and should be verified before closing.
Milestone

Comments

@teecj98
Copy link

teecj98 commented Apr 26, 2024

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

@teecj98 teecj98 added Bug Needs Triage If there is a suspected stream issue, apply this label to triage if it is something we should fix. labels Apr 26, 2024
@robwalch
Copy link
Collaborator

robwalch commented Apr 26, 2024

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?

@robwalch robwalch added Confirmed and removed Needs Triage If there is a suspected stream issue, apply this label to triage if it is something we should fix. labels Apr 26, 2024
@robwalch
Copy link
Collaborator

robwalch commented May 3, 2024

Hi @teecj98,

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

@robwalch robwalch added this to the 1.6.0 milestone May 3, 2024
@robwalch robwalch added the Verify Fixed An unreleased bug fix has been merged and should be verified before closing. label May 4, 2024
robwalch added a commit that referenced this issue May 4, 2024
* Update parser pattern to not terminate segment URLs on unicode white-space
Fixes #6381

* Add test for irregular white-space in segment URIs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Confirmed Verify Fixed An unreleased bug fix has been merged and should be verified before closing.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants