diff options
| author | erdgeist <erdgeist@erdgeist.org> | 2026-07-10 18:07:15 +0200 |
|---|---|---|
| committer | erdgeist <erdgeist@erdgeist.org> | 2026-07-10 18:07:15 +0200 |
| commit | c9401e45433ea45b46f9a8faf1e7e537e4683244 (patch) | |
| tree | c2fabb1942a257f64b4be0c3ab5a5d5bff717d25 /app/helpers | |
| parent | ed9e846d1d85fa326389982e16bbc8799f2001c0 (diff) | |
Fix rrule/url column overflow on events#index
Long RRULEs previously overflowed their column with no wrap point;
now escaped and rendered with a <wbr> after each semicolon, so a
long rule wraps at a clause boundary instead of running off the
table. Deliberately not truncated -- a cut-off RRULE's trailing
clause (BYDAY, BYMONTH, etc.) is usually the most specific part.
The url column is now a real link, truncated with an ellipsis at a
fixed width -- deliberately no tooltip, since hovering a real link
already shows the full address in the browser's own status bar.
rrule_with_break_opportunities splits on the raw string's own
semicolons before escaping each piece, not after -- escaping first
and searching the result for semicolons also matches the ones inside
</> entities, corrupting anything containing a literal < or >.
Diffstat (limited to 'app/helpers')
| -rw-r--r-- | app/helpers/events_helper.rb | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/app/helpers/events_helper.rb b/app/helpers/events_helper.rb index 8a9a878..5e84f53 100644 --- a/app/helpers/events_helper.rb +++ b/app/helpers/events_helper.rb | |||
| @@ -1,2 +1,13 @@ | |||
| 1 | require 'cgi' | ||
| 2 | |||
| 1 | module EventsHelper | 3 | module EventsHelper |
| 4 | # Insert a zero-width break opportunity after each semicolon, so a long | ||
| 5 | # RRULE can wrap at a clause boundary instead of overflowing its column. | ||
| 6 | # Deliberately <wbr>, not ellipsis -- unlike a URL, an RRULE's trailing | ||
| 7 | # characters (BYDAY, BYMONTH, etc.) are usually the most specific part, | ||
| 8 | # and truncating them would hide exactly the wrong end of the string. | ||
| 9 | def rrule_with_break_opportunities(rrule) | ||
| 10 | return "" if rrule.blank? | ||
| 11 | raw(rrule.split(';', -1).map { |part| CGI.escapeHTML(part) }.join(';<wbr>')) | ||
| 12 | end | ||
| 2 | end | 13 | end |
