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

Sanitize path separators contained in assets_path depending on operating system #221

Open
frigvid opened this issue Nov 29, 2022 · 0 comments

Comments

@frigvid
Copy link

frigvid commented Nov 29, 2022

The resource path after {{assets_path}} in the base.html are hard-coded, but you are not sanitizing the path that {{assets_path}} contains. This may have been the cause of #64, #74 and #199 if they were using Windows-based devices. It will work fine on unix-based devices, as they use forward slashes by default. But Windows does not.

Currently, the output ends up looking like this: C:\Users\<user>\AppData\Roaming\Python\Python310\site-packages\report\assets/gitstats.css. The use of mixed path separators is what is breaking it on Windows-based devices.

This needs to be implemented to ensure reliable use and not requiring the use of --copy-assets on all Windows-based devices.

A little side-note; Windows Vista and up support using forward slashes in paths, but still uses backslashes by default. If you merely replace the backslashes from the path you get from Windows devices and replace them with forward slashes, it will work.

I'm not entirely sure which file this is defined in, but if it is htmlreportcreator.py then appending .replace("\\","/") to self.assets_path = os.path.join(HERE, self.assets_subdir) may be enough. Though depending on whether or not the output is only a single backslash or two backslashes, the replace needs to be modified accordingly. Either way, I don't think that should impact unix-based devices, but that should be tested to make sure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant