diff --git a/allianceauth/framework/staticfiles/storage.py b/allianceauth/framework/staticfiles/storage.py index 489b2a79..c0dae084 100644 --- a/allianceauth/framework/staticfiles/storage.py +++ b/allianceauth/framework/staticfiles/storage.py @@ -25,6 +25,22 @@ class AaManifestStaticFilesStorage(ManifestStaticFilesStorage): Custom static files storage that ignores missing files. """ + @classmethod + def _cleanup_name(cls, name: str) -> str: + """ + Clean up the name by removing quotes. + This method is used to ensure that the name does not contain any quotes, + which can cause issues with file paths. + + :param name: The name of the static file. + :type name: str + :return: The cleaned-up name without quotes. + :rtype: str + """ + + # Remove quotes from the name + return name.replace('"', "").replace("'", "") + def __init__(self, *args, **kwargs): """ Initialize the static files storage, ignoring missing files. @@ -39,25 +55,27 @@ class AaManifestStaticFilesStorage(ManifestStaticFilesStorage): super().__init__(*args, **kwargs) - def hashed_name(self, name, *args, **kwargs): + def hashed_name(self, name, content=None, filename=None): """ Generate a hashed name for the given static file, ignoring missing files. Ignore missing files, e.g. non-existent background image referenced from css. Returns the original filename if the referenced file doesn't exist. - :param name: - :type name: - :param args: - :type args: - :param kwargs: - :type kwargs: - :return: - :rtype: + :param name: The name of the static file to hash. + :type name: str + :param content: The content of the static file, if available. + :type content: bytes | None + :param filename: The original filename of the static file, if available. + :type filename: str | None + :return: The hashed name of the static file, or the original name if the file is missing. + :rtype: str """ try: - return super().hashed_name(name, *args, **kwargs) + clean_name = self._cleanup_name(name) + + return super().hashed_name(clean_name, content, filename) except ValueError as e: if settings.DEBUG: # In debug mode, we log the missing file message