Skip to content
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

Add check in splitCells to prevent calling trim on undefined #2372

Merged
merged 1 commit into from Jan 27, 2022

Conversation

zbialecki
Copy link
Contributor

@zbialecki zbialecki commented Jan 26, 2022

Marked version: 4.0.11
Markdown flavor: GitHub Flavored Markdown

Description

Fixes #2371

Expectation

With this change I expect the example given in the issue to not cause a JavaScript error.

Result

The test case no longer throws an error and instead renders the table properly.

What was attempted

This PR adds a simple check to the splitCells helper function that validates that the cells array isn't empty before calling cells[cells.length - 1].trim(). This prevents the error "Cannot read properties of undefined (reading 'trim')" from being thrown.

Contributor

  • Test(s) exist to ensure functionality and minimize regression (if no tests added, list tests covering this PR); or,
  • no tests required for this PR.
  • If submitting new feature, it has been documented in the appropriate places.

Committer

In most cases, this should be a different person than the contributor.

@vercel
Copy link

vercel bot commented Jan 26, 2022

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/markedjs/markedjs/HduowmakdRbDXEJt9n5CzVx6maj2
✅ Preview: https://markedjs-git-fork-zbialecki-fix-table-space-error-markedjs.vercel.app

Copy link
Member

@UziTech UziTech left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! 💯

@UziTech UziTech merged commit ed66bf8 into markedjs:master Jan 27, 2022
@github-actions
Copy link

🎉 This PR is included in version 4.0.12 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Table markdown followed by non-breaking space causes crash
3 participants