diff --git a/frontends/src/tools/strings.py b/frontends/src/tools/strings.py index 400f855b..632b616d 100644 --- a/frontends/src/tools/strings.py +++ b/frontends/src/tools/strings.py @@ -18,6 +18,7 @@ # along with this program. If not, see . import re +from feed.atom import Content def getURLParams(url): @@ -72,3 +73,24 @@ def addURLToImage(string): return '%s' % (url, match.group(0)) pattern = r"""]* src="([^"]+)"[^>]*>""" return re.sub(pattern, repl, string) + + +def fixXHTMLLinks(xhtml): + """Add http:// if the scheme is missing and force opening in a new window. + + @param string (unicode): XHTML Content + """ + subs = [] + for match in re.finditer(r'', xhtml): + tag = match.group(0) + url = re.search(r'href="([^"]*)"', tag) + if url: + if not re.search(r'target="([^"]*)"', tag): # no target + subs.append((tag, '