Any single quotes that appear in commit messages are escaped to ' in the commitlog - fine so far.

Unfortunately, whatever filter renders issue links then inserts a link to make it &<a href="/node/039">#039</a>;. Oops. This also breaks the apostrophe entity.

I'm not sure what the best approach is, here - clearly the markup does need to be escaped before the links are added, and check_plain() uses ENT_QUOTES.

Adding (?<!&) to the regex pattern would make it not match #\d* preceded by an ampersand.

Alternatively, adding ENT_HTML5 to core's check_plain() (which was added in PHP 5.4, and might make sense) would avoid the numerical entity and make it print &apos;.

Comments

cburschka’s picture

Issue summary: View changes
cburschka’s picture

Addendum: Never mind the ENT_HTML5, I was stuck on D8. Obviously, D7 core can't use PHP 5.4 features yet.

cburschka’s picture

Status: Active » Needs review
StatusFileSize
new820 bytes

I haven't taken the time to set up a test environment for this module, but the regex seems to do what it should.

php > var_dump(preg_replace('/#(\d+)\b/i', '<a href="node/\\1">#\\1</a>', htmlspecialchars("This isn't a commit message for issue #2474005.", ENT_QUOTES)));
string(102) "This isn&<a href="node/039">#039</a>;t a commit message for issue <a href="node/2474005">#2474005</a>."
php > var_dump(preg_replace('/(?<!&)#(\d+)\b/i', '<a href="node/\\1">#\\1</a>', htmlspecialchars("This isn't a commit message for issue #2474005.", ENT_QUOTES)));
string(79) "This isn&#039;t a commit message for issue <a href="node/2474005">#2474005</a>."

cburschka’s picture

Status: Needs review » Closed (duplicate)
Related issues: +#2392847: HTML entities prevalent on git log pages