GDevelop icon indicating copy to clipboard operation
GDevelop copied to clipboard

Feat: Fix img hash tag preview issue in corsawareimage.js issue #4015

Open jposeyjr opened this issue 2 years ago • 6 comments

A simple fix for https://github.com/4ian/GDevelop/issues/4015 by encoding the url and removing special chars as recommended by the MDN page. here I also attached screen shots showing it now working and the break point showing full path with the # file name. Screen Shot 2022-06-24 at 5 39 32 PM Screen Shot 2022-06-24 at 5 39 54 PM Screen Shot 2022-06-24 at 5 40 50 PM

jposeyjr avatar Jun 24 '22 23:06 jposeyjr

Hi! Thanks for the PR :) Can you confirm images with a # will also work when previewing and exporting a game, both on the desktop app and the web-app? Also, is there a reason for not using the encodeURIComponent function - could there be other "special" characters like # creating issues?

4ian avatar Jun 25 '22 17:06 4ian

Not ready yet, found some issues.

jposeyjr avatar Jun 26 '22 00:06 jposeyjr

@4ian I fixed the preview, that was something I thought was working but it wasn't that was my bad :). The export "worked" in that it exported them but there is an error in PIXI.JS when trying to view the game. It seems to encode the space but not the # so that is the same issue. Would that be an issue on PIXI.js repo ?? Or would you want the version we have modified? Sorry not my project so don't want to assume the workflow with vendor scripts.

Screen Shot 2022-06-26 at 12 09 45 PM Exported project running index.html on live server extension. Screen Shot 2022-06-26 at 12 27 21 PM

jposeyjr avatar Jun 26 '22 17:06 jposeyjr

Any updates on this?

jposeyjr avatar Jul 07 '22 03:07 jposeyjr

Sorry I missed the notification!

I would be interested to see what is needed to fix this in the game engine too, to ensure we have something working end to end... I've not been able to reflect a lot of this, but I wonder why we have to do a special handling of these characters and if there is something more complex (or more simple?) behind this 🤔

4ian avatar Jul 11 '22 09:07 4ian

So part of the problem is that img tags and the way urls work. That was what I fixed but hashtags shouldn’t be in urls at all for files or most things. As they are used for internal anchors in the url schematic.

When I stepped through the breakpoints it seems pixi doesn’t encode urls either. Honestly all urls should be encoded regardless of solution just from best practices stand point and security.

It doesn’t help how many different things touch and use the url with no good linking between them. Trying to find the best place to encode it was tough too, but that I leave to my inexperience with the code base.

jposeyjr avatar Jul 14 '22 16:07 jposeyjr