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

toLeopard: Trouble with slashes and question marks in asset URLs (normalize/sanitize costume and sound names?) #140

Open
towerofnix opened this issue May 28, 2024 · 0 comments
Labels
bug Something isn't working discussion Looking for feedback and input fmt: Leopard Pertains to Leopard format (JavaScript)

Comments

@towerofnix
Copy link
Member

toLeopard currently defines a default function for getAssetURL, which takes the type of the asset (costume/sound), the target's CapitalCamelCased name, the name as-is of the asset, and the asset's file extension.

This causes a few concerns and troubles when actually generating or serving those assets:

  • Slashes represent directories. This seems like it impacts generation/serving, haven't looked into carefully yet.
  • Question marks represent query strings. Can be trouble when serving static files.
  • .. and . are invalid names for files, and so are files that end with a . (https://superuser.com/a/1434917)... but we avoid these, because we always include .${ext} as part of (and the end of) the string.
  • Though, assets that are currently named ../../../../spooky may be a cause for security trouble.

It would be nice to just use encodeURIComponent but I'm honestly not sure if that's sufficient for normal static file servers.

The other approach is to sanitize asset names, either inside getAssetURL or before passing there. We "sanitize" target names by CapitalCamelCasing them already, so it's not totally unreasonable to do similar with costume names. I think I'd rather do this work outside of getAssetURL because forcing custom implementations to do similar work seems like a source of trouble, if at the end of the day we're asking for and expecting a URL anyway (so best to avoid characters that cause trouble for typical URLs).

We need to make sure if we change anything about getAssetURL internally, other custom getAssetURL (in toLeopard consumers) are updated accordingly. Probably just leopard-website, if any.

@towerofnix towerofnix added bug Something isn't working discussion Looking for feedback and input fmt: Leopard Pertains to Leopard format (JavaScript) labels May 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working discussion Looking for feedback and input fmt: Leopard Pertains to Leopard format (JavaScript)
Projects
None yet
Development

No branches or pull requests

1 participant