modmore / Gitify

Command line toolkit to make managing a MODX site in git a lot easier.
MIT License
122 stars 55 forks source link

Strip file/path name (resource uri) for non alphanumeric characters #100

Open hansek opened 9 years ago

hansek commented 9 years ago

There is a problem if resource alias contains not standard (alphanumeric) characters (e.g. prefix-“content”-suffix).

If this is stored to filesystem on windows it is different from state stored in GIT repo on some *nix machine.

Solution could be to strip all non alpha-numeric characters from file/directory name and to be name of file/directory unique, lets use suffix with resource ID.

Example: Resorce alias: prefix-“content”-suffix Filename: prefix-content-suffix--45 (where 45 is resource ID)

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/19435019-strip-file-path-name-resource-uri-for-non-alphanumeric-characters?utm_campaign=plugin&utm_content=tracker%2F2783338&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F2783338&utm_medium=issues&utm_source=github).
Mark-H commented 9 years ago

Is it even valid to use quotes in a uri/alias? The file path for objects is cleaned through the modResource::filterPathSegment function in https://github.com/modmore/Gitify/blob/master/src/Command/ExtractCommand.php#L226, while it assumes the uri (alias) of the object was already cleaned up with that method when it was set...

hansek commented 9 years ago

Maybe it's not valid, but nowadays you can have even utf-8 in URL (alias) and if you don't have clean (properly clean only for safe characters) alias in MODX you will get this alias as filename and problem is here.

Imho I think this functionality should be part of Gitify, because otherwise there could be a problem (i got into this situation few times) that extract command saves not clean filename (even with utf8 characters) with different characters depend on your OS (*nix vs. windows)

math-u commented 8 years ago

+1