-
-
Notifications
You must be signed in to change notification settings - Fork 9.5k
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
[AssetMapper] Handle assets with non-ascii characters in dev server #53260
[AssetMapper] Handle assets with non-ascii characters in dev server #53260
Conversation
Does it work fully for you after this update ? For me it still returns 404's, trying to figure why :| |
Thanks for this!
This is the right approach - probably adding the new You might also be able to create a new directory next to the existing fixtures directories - e.g. |
My real use case fail with a PNG image. Looks like there something more with a file that could be imported. Let's dig into this! |
I created a reproducer to show the issue: https://github.com/fbourigault/asset-mapper-non-ascii/commit/0834e39d85a257039e5d4aee756e3a9ee8cda63c So the issue happens with js imports, css imports and also images. In the 3 cases, using So, I'm now back to work on tests. and I ran into a weird issue after I added a --- Expected
+++ Actual
@@ @@
4 => 'file4.js'
5 => 'subdir/file5.js'
6 => 'subdir/file6.js'
- 7 => 'voilà.css'
+ 7 => 'voilà.css'
) Does anyone know why both added or removed array entries are the same? EDIT: seems to be an issue related to my machine as there are no CI failure for AssetMapper. |
I tried you reproducer, and duplicated the symfony logo as Then updated the index.html file
It did not work for me.. what about you ? |
After some digging, it seems to me we may need some work (unicode normalisation at several places) to handle macOS (firefox?) vs PHP encoding of accentuated characters " Imho: this would probably require another/distinct PR (as yours already fixes spaces and biggest encoding problems with the rawurldecode) ... |
3d879e8
to
983c5a3
Compare
Thank you for digging!!! That's right I use macOS. For now, I copy/pasted the |
So the problem is that the AssetMapper stores/load pathes in UTF-8, normalized in form D, and the Request gives a path in form C Just after the line where you added the rawurldecode, if you add, i think all tests will go green.
So we could use this method ... but it's in the Intl extension, and it would be weird to require an extension for such a use case. Let's try magic...Focusing.... Invoking the expert in encoding and unicode...... @nicolas-grekas ? 👼 |
Tests are already green since I ensured that U+OOE0 is used everywhere. So the NFC/NFD thing remains. I've updated my reproducer (https://github.com/fbourigault/asset-mapper-non-ascii/commit/09414a8c6a73b8b41008aa3aa66b3cd6851b6b4a) to handle this case. It works fine when assets are compiled to I'm not sure it's something we should take care. Isn't the developer responsibility to have the file on disk using the same code points as the reference in assets/templates? |
Agreed ! As i said this can be dealt (or not) in another PR... as yours fixes the bug you wrote it for :) (but it's not just a question of developer responsability, it's related to the browser / os.. now as it's only in dev, and no one raised this before, it's probably not something that happen too much in real world 😅 ) |
This is ready for a review. CI failures are not related to this PR. |
eb95109
to
27e3d2b
Compare
Thank you @fbourigault. |
This PR was merged into the 6.4 branch. Discussion ---------- [AssetMapper] fix tests | Q | A | ------------- | --- | Branch? | 6.4 | Bug fix? | no | New feature? | no | Deprecations? | no | Issues | | License | MIT Move the new directory introduced in #53260 to the `Fixtures` directory (`fixtures` had been renamed in #52169). Commits ------- 48cf213 fix tests
In
AssetMapperDevServerSubscriber
,$event->getRequest()->getPathInfo()
is used to get the path of the asset to serve. AsRequest::getPathInfo()
returns the raw path, if the requested asset contains non-ascii characters in it's path, a 404 is returned instead of the asset because of the encoded path info.Using
rawurldecode
enabled handling of encoded paths.I just pushed the use of the
rawurldecode
for now as don't known how to test this properly.I tried renaming
dir1/file1.css
todir1/file 1.css
or creating a newand voilà.css
but both approches affect many other tests.How could I test this properly?