Index: cms/converters.py |
=================================================================== |
--- a/cms/converters.py |
+++ b/cms/converters.py |
@@ -127,31 +127,37 @@ class Converter: |
s, flags=re.S) |
def re_escape(s): |
return re.escape(escape(s)) |
# Extract tag attributes from default string |
default, saved_attributes, fixed_strings = self._attribute_parser.parse(default, self._params["page"]) |
# Get translation |
- if self._params["locale"] != self._params["defaultlocale"] and name in localedata: |
+ locale = self._params["locale"] |
+ if locale != self._params["defaultlocale"] and name in localedata: |
result = localedata[name].strip() |
else: |
result = default |
# Insert fixed strings |
for i in range(len(fixed_strings)): |
result = re.sub(r"\{%d\}" % (i + 1), fixed_strings[i], result, 1) |
# Insert attributes |
result = escape(result) |
+ def stringify_attribute((name, value)): |
+ if name == "href": |
+ value = self._params["source"].resolve_link(value, locale)[1] or value |
Wladimir Palant
2015/04/15 19:13:06
Note that this step isn't really necessary for Mar
|
+ return '%s="%s"' % (escape(name), escape(value)) |
+ |
for tag in self.whitelist: |
saved = saved_attributes.get(tag, []) |
for attrs in saved: |
- attrs = map(lambda (name, value): '%s="%s"' % (escape(name), escape(value)), attrs) |
+ attrs = map(stringify_attribute, attrs) |
result = re.sub( |
r"%s([^<>]*?)%s" % (re_escape("<%s>" % tag), re_escape("</%s>" % tag)), |
r'<%s %s>\1</%s>' % (tag, " ".join(attrs), tag), |
result, 1, flags=re.S |
) |
result = re.sub( |
r"%s([^<>]*?)%s" % (re_escape("<%s>" % tag), re_escape("</%s>" % tag)), |
r"<%s>\1</%s>" % (tag, tag), |