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

RGBELoader magic header check #20839

Closed
Usnul opened this issue Dec 5, 2020 · 3 comments · Fixed by #20887
Closed

RGBELoader magic header check #20839

Usnul opened this issue Dec 5, 2020 · 3 comments · Fixed by #20887

Comments

@Usnul
Copy link
Contributor

Usnul commented Dec 5, 2020

Describe the bug

RGBELoader checks for magic token at the start of the file:

/* if you want to require the magic token then uncomment the next line */
if ( ! ( match = line.match( magic_token_re ) ) ) {
return rgbe_error( rgbe_format_error, 'bad initial token' );
}

I have a file that has the said header:
image
Loader doesn't recognize the magic token though.

Here's what line contents are when printed to console:
image

Now the curious part here is if you try to copy that and check the match again:
image
All looks good, however, if you try it on the line directly, you will see this:
image

The problem is that there's a 
 at the end (carriage return):
image
image

A bit extra:
image
It looks like both 13 and 10 are interpreted as NEW_LINE char by the ingestion function fget

To Reproduce

  • can't share the file at this moment

Code

Live example

  • can't share the file at this moment

Expected behavior

I'm not sure, I believe this should be treated as a valid header. This problem did not occur when using r107, so it looks like a regression bug. But perhaps someone more familiar with the RGBE spec can clarify.

Screenshots

see above

Platform:

  • Device: [Desktop]
  • OS: [Windows]
  • Browser: [Chrome]
  • Three.js version: [r??? - yes, 123]
@Mugen87 Mugen87 added the Loaders label Dec 5, 2020
@gkjohnson
Copy link
Collaborator

I can't find anything online that states the bytes that come after #?RADIANCE should be restricted. This reference on the spec seems to indicate that it's enough for the first bytes be #?RADIANCE and that a newline does not need to follow.

Changing magic_token_re from this

magic_token_re = /^#\?(\S+)$/

to this

magic_token_re = /^#\?(\S+)/

seems like a fix.

@mrdoob
Copy link
Owner

mrdoob commented Dec 8, 2020

@Usnul do you mind testing that fix?

@Usnul
Copy link
Contributor Author

Usnul commented Dec 12, 2020

Yes, this works.

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

Successfully merging a pull request may close this issue.

4 participants