mirror of
https://github.com/discourse/discourse.git
synced 2026-08-09 12:38:21 -05:00
Previously, poll extraction used a greedy regex to strip quotes from raw
content before parsing:
raw = raw.sub(/\[quote.+\/quote\]/m, '')
This matched from the first `[quote` to the LAST `[/quote]`,
accidentally removing everything in between - including the actual poll
- when a post contained multiple quotes. This bug has existed since the
quote-stripping was introduced in April 2022 (461936f2).
Instead of manipulating raw content with regex, we now filter polls at
the Nokogiri level by excluding any inside a blockquote:
.reject { |p| p.ancestors("blockquote").any? }
This approach is more robust, handles edge cases like nested quotes and
malformed markup, and matches what the frontend JS already does.