diff --git a/news/4237.bugfix.md b/news/4237.bugfix.md new file mode 100644 index 0000000000..8e5ffa17e7 --- /dev/null +++ b/news/4237.bugfix.md @@ -0,0 +1 @@ +Fix broken CSS on 404 pages inside private folders @dobri1408 diff --git a/src/Products/CMFPlone/browser/exceptions.py b/src/Products/CMFPlone/browser/exceptions.py index 0d843bf93b..7d4797e9c1 100644 --- a/src/Products/CMFPlone/browser/exceptions.py +++ b/src/Products/CMFPlone/browser/exceptions.py @@ -30,7 +30,15 @@ def __call__(self): # and sets the proper location header return - self.context = self.__parent__ + # Always use portal root as context to ensure resources load correctly + current = self.__parent__ + while hasattr(current, "__parent__") and current.__parent__ is not None: + if hasattr(current, "meta_type") and current.meta_type == "Plone Site": + break + current = current.__parent__ + + self.context = current + self.__parent__ = current # Also update __parent__ to ensure consistency request = self.request exc_type, value, traceback = sys.exc_info()