Skip to content

fix: math parsing hangs webchat #5377

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Nov 13, 2024
Merged

fix: math parsing hangs webchat #5377

merged 5 commits into from
Nov 13, 2024

Conversation

OEvgeny
Copy link
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
@compulim compulim merged commit f4bb6a9 into main Nov 13, 2024
27 checks passed
@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