Skip to content

Commit

Permalink
Replace iarna/toml with smol-toml
Browse files Browse the repository at this point in the history
Our build logs were complaining:

> node_modules/@iarna/toml/lib/toml-parser.js (153:22): Use of eval in "node_modules/@iarna/toml/lib/toml-parser.js" is strongly discouraged as it poses security risks and may cause issues with minification.

Unfortunately, iarna/toml appears to be unmaintained,
so this likely won't get fixed. This patch replaces
it with another toml parser that causes no
build complaints and is actively maintained.
  • Loading branch information
Arnei committed Jul 10, 2024
1 parent d981113 commit b9ef5fb
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 19 deletions.
27 changes: 12 additions & 15 deletions package-lock.json

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

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,10 @@
"@emotion/react": "^11.11.4",
"@emotion/styled": "^11.11.5",
"@fontsource-variable/roboto-flex": "^5.0.15",
"@iarna/toml": "^2.2.5",
"@mui/material": "^5.15.21",
"@opencast/appkit": "^0.3.0",
"@reduxjs/toolkit": "^2.2.6",
"@testing-library/jest-dom": "^6.4.6",
"@types/iarna__toml": "^2.0.5",
"@types/react": "^18.3.3",
"@types/react-dom": "^18.3.0",
"deepmerge": "^4.3.1",
Expand Down Expand Up @@ -41,6 +39,7 @@
"react-virtualized-auto-sizer": "^1.0.24",
"react-window": "^1.8.10",
"redux": "^5.0.1",
"smol-toml": "^1.2.2",
"standardized-audio-context": "^25.3.72",
"typescript": "^5.5.2",
"uuid": "^10.0.0",
Expand Down
4 changes: 2 additions & 2 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*
* Also does some global hotkey configuration
*/
import parseToml from "@iarna/toml/parse-string";
import { parse } from "smol-toml";
import deepmerge from "deepmerge";
import { Flavor } from "./types";

Expand Down Expand Up @@ -222,7 +222,7 @@ const loadContextSettings = async () => {
}

try {
return parseToml(await response.text());
return parse(await response.text());
} catch (e) {
console.error(`Could not parse "${settingsPath}" as TOML: `, e);
throw new SyntaxError(`Could not parse "${settingsPath}" as TOML: ${e}`);
Expand Down

0 comments on commit b9ef5fb

Please sign in to comment.