twinkle icon indicating copy to clipboard operation
twinkle copied to clipboard

Protection template removal newline issue

Open Eejit43 opened this issue 1 year ago • 1 comments

As seen in this edit, Twinkle removes too many newlines when removing a page protection template.

Eejit43 avatar Mar 13 '23 19:03 Eejit43

The issue seems to arise from the regex used for finding and removing the protection template (twinkleprotect.js#L1447) checking for whitespace on both sides of the main template finding

The rough layout of the regex is: optional /*, whitespace, optional <noinclude>, whitespace, the template, whitespace, optional </noinclude>, whitespace, optional */, whitespace Perhaps moving the \s* into the optional capture groups for /* and <noinclude> could help prevent this issue? This would mean it only attempts to remove whitespace ahead of it in regular occurances of the text, which I imagine would be fine

9382 avatar Nov 14 '23 18:11 9382