Commit fda8f463 authored by Jean-Paul Smets's avatar Jean-Paul Smets

Added base support base on HTML content.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@13679 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 271a6c6e
...@@ -380,6 +380,7 @@ class Document(XMLObject, UrlMixIn, ConversionCacheMixin, SnapshotMixin): ...@@ -380,6 +380,7 @@ class Document(XMLObject, UrlMixIn, ConversionCacheMixin, SnapshotMixin):
href_parser = re.compile('<a[^>]*href=[\'"](.*?)[\'"]',re.IGNORECASE) href_parser = re.compile('<a[^>]*href=[\'"](.*?)[\'"]',re.IGNORECASE)
body_parser = re.compile('<body[^>]*>(.*?)</body>', re.IGNORECASE + re.DOTALL) body_parser = re.compile('<body[^>]*>(.*?)</body>', re.IGNORECASE + re.DOTALL)
title_parser = re.compile('<title[^>]*>(.*?)</title>', re.IGNORECASE + re.DOTALL) title_parser = re.compile('<title[^>]*>(.*?)</title>', re.IGNORECASE + re.DOTALL)
base_parser = re.compile('<base[^>]*href=[\'"](.*?)[\'"][^>]*>', re.IGNORECASE + re.DOTALL)
# Declarative security # Declarative security
security = ClassSecurityInfo() security = ClassSecurityInfo()
...@@ -1134,13 +1135,12 @@ class Document(XMLObject, UrlMixIn, ConversionCacheMixin, SnapshotMixin): ...@@ -1134,13 +1135,12 @@ class Document(XMLObject, UrlMixIn, ConversionCacheMixin, SnapshotMixin):
Returns the content base URL based on the actual content or Returns the content base URL based on the actual content or
on its URL. on its URL.
""" """
# XXX TODO - try to retrieve base URL from content
# If no base_url defined, define the base URL from our URL
base_url = self.asURL() base_url = self.asURL()
base_url_list = base_url.split('/') base_url_list = base_url.split('/')
if len(base_url_list): if len(base_url_list):
if base_url_list[-1]: if base_url_list[-1] and base_url_list[-1].find('.') > 0:
# Cut the trailing part in http://www.some.site/at/trailing.html # Cut the trailing part in http://www.some.site/at/trailing.html
# but not in http://www.some.site/at
base_url = '/'.join(base_url_list[:-1]) base_url = '/'.join(base_url_list[:-1])
return base_url return base_url
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment