From e8361a60d11ced06f42e9637ba64965ec08e4c32 Mon Sep 17 00:00:00 2001 From: Griatch Date: Tue, 7 Dec 2010 22:27:50 +0000 Subject: [PATCH] A file was not properly added in the last commit. Added now. --- src/server/webclient.py | 2 +- src/utils/text2html.py | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/server/webclient.py b/src/server/webclient.py index ac514d37d5..1f3a049707 100644 --- a/src/server/webclient.py +++ b/src/server/webclient.py @@ -25,7 +25,7 @@ from django.utils.functional import Promise from django.utils.encoding import force_unicode from django.conf import settings from src.utils import utils -from src.utils.ansi2html import parse_html +from src.utils.text2html import parse_html from src.config.models import ConnectScreen from src.server import session, sessionhandler diff --git a/src/utils/text2html.py b/src/utils/text2html.py index 745189c596..355bc2ca48 100644 --- a/src/utils/text2html.py +++ b/src/utils/text2html.py @@ -76,6 +76,11 @@ class TextToHTMLparser(object): "Extra method for cleaning linebreaks" return text.replace(r'\n', r'
') + def convert_urls(self, text): + "Replace urls (http://...) by valid HTML" + regexp = r"((ftp|www|http)(\W+\S+[^).,:;?\]\}(\) \r\n$]+))" + return re.sub(regexp, r'\1', text) + def do_sub(self, m): "Helper method to be passed to re.sub." c = m.groupdict() @@ -118,13 +123,14 @@ class TextToHTMLparser(object): result = self.remove_bells(result) result = self.convert_linebreaks(result) result = self.remove_backspaces(result) + result = self.convert_urls(result) # clean out eventual ansi that was missed result = ansi.parse_ansi(result, strip_ansi=True) return result -HTML_PARSER = TextToTMLparser() +HTML_PARSER = TextToHTMLparser() # # Access function