I’m building app combine between Rails and Phoenix. I put Phoenix behind Rails, just render HTML response from Rails.
I have an issue when showing images. Several images have colon symbol in name, something like ‘abcd:xzy.jpg’. It seems Phoenix can’t render images look like that.
Because my Rails app was built a long time ago, so I don’t wanna change the database.
so How I can render images have colon symbol on Phoenix?
Please let me know.
I’ve seen this problem before, in my case Phoenix is acting as the web server (via Cowboy), Rails generates the HTML, Phoenix forwards headers to Rails to allow the Rails app to function normally. (This allows me to replace parts of the app to improve performance allowing the legacy Rails app to handle the non-Elixir part of the project)
When static assets have colons in the file name, there is an “invalid path for static asset” error. In rails this would be solved by adding a constraint parameter to the route, unfortunately I have not found a solution in Phoenix.
I believe in the past it was considered that colons within a URI path was a potential security issue, specifically on Windows (I know that ASP.NET, for example does (or used to, I’m unsure about nowadays) not allow colons). I don’t have any commentary on if it actually is a security issue in 2019, but there is, at the very least, a multitude of debates that turn up on Stackoverflow and other sites about whether or not a colon is URL-safe.
If I had to guess, the author of that plug probably marked it as invalid for that reason. Maybe this is a chance for a pull request to make it configurable which characters are invalid?