From 4706bbe7aeff71a596a0018918ca70b17bb9193e Mon Sep 17 00:00:00 2001 From: "Robin H. Johnson" Date: Tue, 5 Aug 2008 00:41:34 +0000 Subject: Fix for bug #232234. --- web/lib/changelog_formatter.py | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/web/lib/changelog_formatter.py b/web/lib/changelog_formatter.py index 9a4ab70..872cc98 100644 --- a/web/lib/changelog_formatter.py +++ b/web/lib/changelog_formatter.py @@ -33,8 +33,9 @@ def _single_pass_re_loop(reo, callback, instr): """For every match of the given regex, replace the entire match with the string given by callback. Callback takes the re.match object.""" - while True: - m = reo.search(instr) + for m in reo.finditer(instr): + #while True: + #m = reo.search(instr) if m is None: break repl = callback(m) @@ -45,7 +46,9 @@ re_email1 = re.compile(r'<([^@ ]+)@gentoo.org>') re_email2 = re.compile(r'([^@ ]+)@gentoo.org') re_file = re.compile(r'([\+-]?)(\S+)([:,]|[:,]$)') re_bugid = re.compile(r'([Bb][uU][gG] ?#?)(\d+)') -re_url = re.compile(r'(http://[\S]+[\w/])([\s).]|$)') +re_url_base = '(https?://[^\s/)>]+(?:/[\S]+)?)' +re_url = re.compile("([\s<(]*)"+re_url_base+"([\s>)]+?.?|$)?") +re_url_notend = re.compile(r'[\s.)>]+$') def _pretty_changelog_pass1(cat, pn, changelog): """Changelog prettification, pass1: replace text with markers""" @@ -84,7 +87,19 @@ def _pretty_changelog_pass1(cat, pn, changelog): return '%s__BUG__%s__/BUG__' % (m.group(1), m.group(2)) newline = _single_pass_re_loop(re_bugid, bug_markup, newline) def url_markup(m): - return '__URL__%s__/URL__%s' % (m.group(1)[7:], m.group(2)) + prefix = m.group(1) + url = m.group(2) + suffix = m.group(3) + if prefix is None: + prefix = '' + if suffix is None: + suffix = '' + extra_suffix = re_url_notend.search(url) + if extra_suffix: + extra_suffix = extra_suffix.group(0) + suffix = extra_suffix + suffix + url = url[0:-len(extra_suffix)] + return '%s__URL__%s__/URL__%s' % (prefix, url, suffix) newline = _single_pass_re_loop(re_url, url_markup, newline) changelog_lines[i] = newline if oldline.endswith(':'): -- cgit v1.2.3-65-gdbad