Skip to content

Commit

Permalink
fix: remove eval (#49)
Browse files Browse the repository at this point in the history
* Update Parser.ts

* Update Parser.ts

* Update Parser.ts

* Update push.yml
  • Loading branch information
menduz authored Jun 8, 2023
1 parent d811e94 commit 1406198
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ name: Test and release
jobs:
install:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@master
- name: Use Node.js 12.x
Expand All @@ -22,6 +25,8 @@ jobs:
- name: lint
run: npm run lint
- name: Publish
uses: menduz/[email protected]
uses: menduz/oddish-action@master
with:
provenance: true
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
11 changes: 9 additions & 2 deletions src/Parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -272,8 +272,15 @@ export class Parser {

try {
if (!targetLex && type.isLiteral) {
// tslint:disable-next-line: no-eval
let src = eval(type.name);


let src: string = type.name.trim();

if (src.startsWith('"')) {
src = JSON.parse(src);
} else if (src.startsWith("'")) {
src = src.replace(/^'(.+)'$/, '$1').replace(/\\'/g, "'");
}

if (src === '') {
return {
Expand Down

0 comments on commit 1406198

Please sign in to comment.