Skip to content

fix: math parsing hangs webchat#5377

Merged
compulim merged 5 commits into
mainfrom
fix/math-hangs
Nov 13, 2024
Merged

fix: math parsing hangs webchat#5377
compulim merged 5 commits into
mainfrom
fix/math-hangs

Conversation

@OEvgeny
Copy link
Copy Markdown
Collaborator

@OEvgeny OEvgeny commented Nov 13, 2024

Fixes

Changelog Entry

Fixed

  • Fixed math parsing that could cause Web Chat to hang when processing certain LaTeX expressions, in PR #5377, by @OEvgeny

Description

This PR addresses a critical issue where Web Chat could hang when parsing certain LaTeX mathematical expressions. The problem occurred specifically when processing escaped sequences in math blocks, particularly affecting expressions with trailing backslashes or incomplete delimiters.

Design

We don't process escape sequences, unless it's an end delimiter. Otherwise we hand processing over to the content state processor which will properly handle line breaks and such.

Specific Changes

  • Renamed escaped function to maybeCloseDelimeter for better clarity of intent
  • Removed redundant character consumption in escape sequence handling
  • Added test case for LLM-generated math expressions with trailing backslashes

-

  • I have added tests and executed them locally
  • I have updated CHANGELOG.md
  • I have updated documentation

Review Checklist

This section is for contributors to review your work.

  • Accessibility reviewed (tab order, content readability, alt text, color contrast)
  • Browser and platform compatibilities reviewed
  • CSS styles reviewed (minimal rules, no z-index)
  • Documents reviewed (docs, samples, live demo)
  • Internationalization reviewed (strings, unit formatting)
  • package.json and package-lock.json reviewed
  • Security reviewed (no data URIs, check for nonce leak)
  • Tests reviewed (coverage, legitimacy)

@OEvgeny OEvgeny marked this pull request as ready for review November 13, 2024 00:10
Comment thread packages/bundle/src/markdown/mathExtension/tokenizer.ts Outdated
Comment thread packages/bundle/src/markdown/mathExtension/tokenizer.ts Outdated
OEvgeny and others added 2 commits November 13, 2024 18:32
Co-authored-by: William Wong <compulim@users.noreply.github.com>
Co-authored-by: William Wong <compulim@users.noreply.github.com>
@compulim compulim merged commit f4bb6a9 into main Nov 13, 2024
@compulim compulim deleted the fix/math-hangs branch November 13, 2024 19:39
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.

2 participants