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

Some c0 characters cause a crash #1

Closed
ChristianMurphy opened this issue Sep 17, 2020 · 1 comment
Closed

Some c0 characters cause a crash #1

ChristianMurphy opened this issue Sep 17, 2020 · 1 comment
Labels
🗄 area/interface This affects the public interface 💪 phase/solved Post is done 👶 semver/patch This is a backwards-compatible fix 🐛 type/bug This is a problem

Comments

@ChristianMurphy
Copy link
Member

ChristianMurphy commented Sep 17, 2020

Subject of the issue

Some short inputs produce RangeError: Maximum call stack size exceeded errors

Your environment

  • OS: Ubuntu
  • Packages: micromark-extension-gfm 0.1.0, micromark 2.6.0
  • Env: node 14

Steps to reproduce

discovered using micromark/micromark#18

var fs = require('fs')
var micromark = require('micromark')
var gfmSyntax = require('micromark-extension-gfm')
var gfmHtml = require('micromark-extension-gfm/html')

var doc = fs.readFileSync('<one of the crash files goes here>')

var result = micromark(doc, {
  allowDangerousHtml: true,
  extensions: [gfmSyntax()],
  htmlExtensions: [gfmHtml]
})

console.log(result)

Run any of the attached files through to reproduce the issue

crash-5ea430ec94fc2ad0111b7a93902717954c33aee70c4580157e2e33f1233b771f.txt
crash-8d29501e5df33f9267a4c3e5756c3f064b02ac17b1a94dd9fed3864065cac8f7.txt
crash-18fa9164e99eede7aef9a4b132dfd102c63af51f5281a5e65f62d7f8a05da2c2.txt
crash-44ddd3dab072ad531b8d1d8bf1de45d1434239863e92eb11e24376a2250833bd.txt
crash-61c581437cca1b8a729dbc7785c87c990a15e64246bc38177a47299817f410d6.txt
crash-199c3bd460de84b1e70363da216e177a93d918f6e4ba3abb485f961ca8f5d20d.txt
crash-0986c194573a3b25288270e3238197192b2c5e16780905f85e6b5d307de17030.txt
crash-3647cb12a83367983354b6aa65573a230990070507444681e6d3c4c19c3d1f8d.txt
crash-a00f61d5c6ccbd0fa0f439bd59fe31ebdaa62dd5fa18bc7a40b6a78df0362220.txt
crash-c89af552ec529a6276432019ad8f404aa630dc590de696c1c164aa1baec4b3a0.txt
crash-d5f7abcafb561be96fb5af1839cd54a47303216105afa9477d072d7fcdc5d6fd.txt

Expected behavior

micromark should not crash

Actual behavior

RangeError: Maximum call stack size exceeded
    at assign (<anonymous>)
    at shallow (/micromark/dist/util/shallow.js:1:1131)
    at now (/micromark/dist/util/create-tokenizer.js:1:21524)
    at Object.enter (/micromark/dist/util/create-tokenizer.js:1:24223)
    at cellBreakHead (/micromark/node_modules/micromark-extension-gfm-table/syntax.js:1:46598)
    at inCellContentHead (/micromark/node_modules/micromark-extension-gfm-table/syntax.js:1:47495)
    at cellBreakHead (/micromark/node_modules/micromark-extension-gfm-table/syntax.js:1:46663)
    at inCellContentHead (/micromark/node_modules/micromark-extension-gfm-table/syntax.js:1:47495)
    at cellBreakHead (/micromark/node_modules/micromark-extension-gfm-table/syntax.js:1:46663)
    at inCellContentHead (/micromark/node_modules/micromark-extension-gfm-table/syntax.js:1:47495)
@ChristianMurphy ChristianMurphy added the 🐛 type/bug This is a problem label Sep 17, 2020
@ChristianMurphy ChristianMurphy changed the title RangeError: Maximum call stack size exceeded Invalid table content can lead to stack overflow Sep 17, 2020
@wooorm wooorm closed this as completed in cd86cf5 Sep 18, 2020
@wooorm
Copy link
Member

wooorm commented Sep 18, 2020

The characters 1, 2, 3, and 4 were mistakenly seen as being some form of whitespace due to a typo, but the whitespace state thought they were content (they are).

Amazing find!

@wooorm wooorm changed the title Invalid table content can lead to stack overflow Some c0 characters cause a crash Sep 18, 2020
@wooorm wooorm added ⛵️ status/released 🗄 area/interface This affects the public interface 👶 semver/patch This is a backwards-compatible fix labels Sep 18, 2020
@wooorm wooorm added the 💪 phase/solved Post is done label Apr 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🗄 area/interface This affects the public interface 💪 phase/solved Post is done 👶 semver/patch This is a backwards-compatible fix 🐛 type/bug This is a problem
Development

No branches or pull requests

2 participants