Issue 3629: HTML entities confuse commentlinks which contain special chcaracters
Status:  New
Owner: ----
Reported by PeterJC...@gmail.com, Oct 26, 2015
Affected Version: 2.8

What steps will reproduce the problem?

1. Add a commentlink with a match which includes a hash '#' (or possibly others, such as ampersand):
~~~~
[commentlink "ticket"]
	match = "#(\\d+)"
	link = http://example.com/trac/ticket/$1
~~~~

2. Ensure the configuration is loaded, then submit a commit which contains a single quote character (as well as a hash-number):
~~~~
Fix #123: Fix use of 'bees'.
~~~~

3. View the page for the patch in gerrit.

What is the expected output?

Only the # in the text should be matched and replaced, giving something like:
~~~~
Fix <a href="...">#123</a>: Fix use of 'bees'.
~~~~

What do you see instead?

The html entity for the single quotes are also matched, converted to links and then re-escaped.
You end up with something like:
~~~~
Fix <a href="...">#123</a>: Fix use of &<a href="...">#39;</a>bees&<a href="...">#39;</a>.
~~~~

Please provide any additional information below.

This can be worked around by explicitly excluding matches which are preceded by ampersands in the match:

~~~~
[commentlink "ticket"]
	match = "[^&]#(\\d+)"
	link = http://example.com/trac/ticket/$1
~~~~