10000 URLs are built incorrectly in some content viewers · Issue #1494 · aces/cbrain · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

URLs are built incorrectly in some content viewers #1494

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

Open
prioux opened this issue Apr 2, 2025 · 3 comments
Open

URLs are built incorrectly in some content viewers #1494

prioux opened this issue Apr 2, 2025 · 3 comments

Comments

@prioux
Copy link
Member
prioux commented Apr 2, 2025

I was watching rails logs and saw these lines:

Started GET "/userfiles/5596075/content?content_loader=raw_content&file_name=CAPT0000001_ReconAll%2Fmri%2Fbrain
.finalsurfs.mgz&viewer_userfile_class=MghFile" for xxx.xxx.xxx.xxx at 2025-04-02 16:02:56 -0400
Processing by UserfilesController#content as */*
  Parameters: {"content_loader"=>"raw_content", "amp"=>nil, "file_name"=>"CAPT0000001_ReconAll/mri/brain.finalsurfs
.mgz", "viewer_userfile_class"=>"MghFile", "id"=>"5596075"}

It's obvious that the parameter 'amp' is a mistake because the query parameters contain an HTML-escaped & instead of the actual '&'

I think this is from the the FileCollection viewer maybe?

@MontrealSergiy
Copy link
Contributor
MontrealSergiy commented Apr 3, 2025

Good catch. The example you noticed indeed came from a File Collection, yet that's how CBRAIN handles all MINC, NifTi or MGH files. this issue occurs with isolated files too. The same kind of URL with html-escaped ampersand is invoked by a single file view as well.

So it seems more related to cbrain-plugins-neuro templates than core CBRAIN

It appears that the MINC/BrainBrowser-based viewer's HTML template is actually disguised JS, and JavaScript may have slightly different escape rules for strings. It does not interpret &amp; the same way HTML does. Preventing escape with raw helper <%= raw content_userfile_path .... %> or even plain search and replace might work. I'd apply some JavaScript escaping with something like escape_javascript .

Luckily, it seems that most browsers still support the semicolon (;) for query parameter separation, so the files are still displayed correctly.

Tell me if I should take a deeper look, or submit a PR.

@prioux
Copy link
Member Author
prioux commented Apr 3, 2025

I just want the code that does this to be fixed, so that the URLs are built properly. I bed it's just a few characters at the right place.

@MontrealSergiy
Copy link
Contributor
MontrealSergiy commented Apr 3, 2025

ok a small PR submitted aces/cbrain-plugins-neuro#300

Remember to flush the cache when testing.

This issue should be migrated to plugins too.

@prioux prioux changed the title URL are built incorrectly in some content viewers URLs are built incorrectly in some content viewers Apr 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants
0