Skip to content

Commit

Permalink
When making relative URIs absolute, use the parent as the relative
Browse files Browse the repository at this point in the history
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.

I had test failures locally before this change but this change
introduced no more failures.  Sorry I can't do better than that.
  • Loading branch information
rpatterson committed Feb 10, 2012
1 parent 3d7b6cb commit 3f7f5db
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
6 changes: 6 additions & 0 deletions CHANGES.txt
Expand Up @@ -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]

Expand Down
10 changes: 7 additions & 3 deletions 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
Expand Down Expand Up @@ -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':
Expand Down

0 comments on commit 3f7f5db

Please sign in to comment.