Skip to content

Keep the ticker and the calendar page fast on titles and descriptions full of "<" - #2079

Closed
svaka2000 wants to merge 1 commit into
Open-Coding-Society:mainfrom
svaka2000:fix/calendar-tag-link-regex
Closed

svaka2000 wants to merge 1 commit into
Open-Coding-Society:mainfrom
svaka2000:fix/calendar-tag-link-regex

Conversation

@svaka2000

Copy link
Copy Markdown
Contributor

Like #2068 did for linked docs, this keeps two more regexes that scan event text from slowing a page down. Any signed-in account can write that text.

What users see:

  • Normal events look the same.
  • A title with a stray < before a tag keeps it now. x < y <b>bold</b> shows as x < y bold in the ticker (main showed x bold).
  • A Slack link with a < in its text, like <https://a.b|x < y>, isn't made a link anymore, and the event window then drops it as an unknown tag (main showed a link reading x < y). Slack writes < in link text as &lt;, so links from Slack don't change.

What changed:

  • The ticker (the Coming up bar on course homes) takes the tags out of a title it treats as HTML (one with a closing tag or an entity like &amp;) with the regex TAG in _projects/systems/courses/js/announcement-calendar/calendar-ticker.js. It went from each < to the next >, so after a closing tag, a long run of < with no > got scanned to the end again from every <.
  • slackToHtml on the calendar page (_projects/systems/calendar/index.md) turns <url|text> into links when you open an event. Its link regex did the same with a description full of <http: links that never close.
  • Both now stop at the next < as well as at >: <[^>]*> became <[^<>]*>, and the link regex's two parts stop at < too.

Other notes:

  • It only matters if Spring can save a title or description longer than 255 characters. Both columns are varchar(255), which MySQL enforces but SQLite doesn't, Spring's code doesn't check the length, and Spring's README says production is on SQLite right now.
  • I compared main's and this branch's versions on 500,000 random titles (built from tags, <, >, entities and words) and 500,000 random descriptions (built from Slack links, |, >, <, *, _, ~, backticks and words). Every difference was one of the two cases above.
  • Playwright opened the live pages in Chrome and in WebKit (Safari's engine, what iPhones use), with Spring and Flask faked, and gave each page main's or this branch's code. One event had a title of </b> and 100,000 <, another a description of 30,000 <http:a links that never close. One run each.
  • In WebKit, the ticker showed up 4.6 s after the course home started loading on main and 2.2 s on this branch. Opening the event on the calendar page took 11.5 s on main and 0.4 s here.
  • In Chrome, opening the event took 4.8 s on main and 0.3 s here. Chrome runs the old title regex fast, so the ticker only slowed down in WebKit.
  • Speed tests: _projects/systems/courses/tests/calendar_ticker.test.mjs has one for the title, and the new _projects/systems/calendar/tests/slack_text.test.mjs reads slackToHtml out of index.md and runs it (the files in tests/ import them). On main they took over a second each and failed their 200 ms limit. Now they take a few milliseconds.
  • I added the rule (stop at the next <) to the calendar part of AGENTS.md and AGENTS_MD_DOCUMENTATION.md.

How to try it:

  1. Check out fix/calendar-tag-link-regex from svaka2000/Pages-JJ.
  2. Run node --test tests/calendar_ticker.test.mjs tests/calendar_slack_text.test.mjs tests/calendar_doc_links.test.mjs tests/calendar_safe_html.test.mjs. It passes in under a second.

@svaka2000

Copy link
Copy Markdown
Contributor Author

Combined into #2089 with the same commits.

@svaka2000 svaka2000 closed this Nov 26, 2026
jm1021 pushed a commit that referenced this pull request Nov 26, 2026
…of "<"

Branch fix/calendar-tag-link-regex, head a22e0d5.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant