Skip to content

Commit

Permalink
Patch luaparse to not fail on unicode chars
Browse files Browse the repository at this point in the history
  • Loading branch information
Maddimax committed Jan 21, 2025
1 parent ec12a6f commit 1879948
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 29 deletions.
19 changes: 5 additions & 14 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

15 changes: 1 addition & 14 deletions src/luaspec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,12 @@ export function jsonFromSpec(spec: string): string {
stdout: data => core.debug(data)
})

const escapedSpec = spec
.split('')
.map(c => {
if (c.charCodeAt(0) < 127) return c
const buf = Buffer.from(c)
return Array.prototype.map
.call(buf, ce => `\\x${ce.toString(16)}`)
.join('')
})
.join('')

const luaSpecScript = luaEnv.parse(escapedSpec.toString())
const luaSpecScript = luaEnv.parse(spec)
const luaSpec = luaSpecScript.exec()

if (!(luaSpec instanceof luainjs.Table)) {
throw new Error('Spec must be a table')
}

console.log('XXXX:', JSON.stringify(luaSpec.toObject()))

return JSON.stringify(luaSpec.toObject())
}

0 comments on commit 1879948

Please sign in to comment.