and to alt="area_url" (for the different clickable areas).
* Now also "title" supported to generate tooltips for the map areas.
* Interwiki links can also be specified in "wiki:MoinMoin/Page" syntax now.
+
+ Version ?
+ * Allow setting any HTML attribute that is allowed by the HTML4.01 spec,
+ except for javascript event handlers.
"""
from MoinMoin import wikiutil, config
from MoinMoin.action import AttachFile
+# Define the valid attributes for map and area elements. These are directly
+# taken from the HTML4.01 spec at http://www.w3.org/TR/html401/ The lists below
+# mimic the structure used in the HTML spec.
+html_core_attrs = ['id', 'class', 'style', 'title']
+html_i18n = ['lang', 'dir']
+html_events = [] # event attributes left out for security reasons.
+html_attrs = html_core_attrs + html_i18n + html_events
+html_map_attrs = html_attrs + ['name']
+html_area_attrs = html_attrs + ['shape', 'coords', 'href', 'nohref', 'alt', 'tabindex', 'accesskey']
def _is_URL(text):
return '://' in text
def _is_allowed_Para(para, allowed_paras):
found = False
+ para += '="'
for p in allowed_paras:
if para.startswith(p):
found = True
# and: pic.png;height="10" onmouseover="ExecuteBadCode()";alt="..";
# and: pic.png;height="10" onmouseover="ExecuteBadCode()";alt="..";
p = _strip_Para(p)
- if _is_allowed_Para(p, ['width="', 'height="', 'alt="', 'title="']):
+ if _is_allowed_Para(p, html_map_attrs):
html += ' %s' % p
# Prepare dict for formatter.image if formatter.rawHTML call fails
key, value = p.split('=', 1)
# and: FrontPage;shape="rect" onmouseover="ExecuteBadCode()";coords="..";
# and: FrontPage;shape="rect" onmouseover="ExecuteBadCode()";coords="..";
i = _strip_Para(i)
- if _is_allowed_Para(i, ['shape="', 'coords="', 'alt="', 'title="']):
+ if _is_allowed_Para(i, html_area_attrs):
html += ' %s' % i
# If there is no alt provided at all, set alt to area_url
if p.lower().find('alt="') == -1: