diff --git a/CHANGES.txt b/CHANGES.txt index 36d33a4..b10c2c4 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -4,6 +4,12 @@ Changelog 1.2 - unreleased ---------------- +- When making relative URIs absolute, use the parent as the relative + root when the context is not folderish. Fixes an issue where + relative URLs from Plone 3, for example, had the wrong URLs under + Plone 4 when a default page was used for a folder. + [rossp] + - Fixed testing error when packaged with a missing README.rst. [maurits] diff --git a/plone/outputfilters/filters/resolveuid_and_caption.py b/plone/outputfilters/filters/resolveuid_and_caption.py index c8da92a..1e14a26 100644 --- a/plone/outputfilters/filters/resolveuid_and_caption.py +++ b/plone/outputfilters/filters/resolveuid_and_caption.py @@ -1,5 +1,5 @@ from ZODB.POSException import ConflictError -from Acquisition import aq_base, aq_acquire +from Acquisition import aq_base, aq_acquire, aq_parent from zExceptions import NotFound from zope.publisher.interfaces import NotFound as ztkNotFound from DocumentTemplate.DT_Util import html_quote @@ -309,8 +309,12 @@ def unknown_starttag(self, tag, attrs): elif resolveuid_re.match(href) is None: # absolutize relative URIs; this text isn't necessarily # being rendered in the context where it was stored - href = urljoin(self.context.absolute_url() + '/', - subpath) + appendix + relative_root = self.context + if not getattr( + self.context, 'isPrincipiaFolderish', False): + relative_root = aq_parent(self.context) + actual_url = relative_root.absolute_url() + href = urljoin(actual_url + '/', subpath) + appendix attributes['href'] = href attrs = attributes.iteritems() elif tag == 'img':