FooSoft / yomichan

Japanese pop-up dictionary extension for Chrome and Firefox.
https://foosoft.net/projects/yomichan
Other
1.05k stars 208 forks source link

JSON schema validation #2138

Open toasted-nutbread opened 2 years ago

toasted-nutbread commented 2 years ago

Schema validation of data is sub-optimal and can cause significant slowdowns for large and complex dictionary files. Some issues were brought up in this comment: https://github.com/FooSoft/yomichan/pull/2129#issuecomment-1126785466.

This issue is intended to track issues and other information related to this topic.

Related issues:

toasted-nutbread commented 2 years ago

Using ajv poses some issues related to content security policy if not compiled: https://ajv.js.org/guide/environments.html#browsers

toasted-nutbread commented 2 years ago

One place where ajv wouldn't be able to be used is profile condition validation. Profile conditions are translated to JSON schemas, which are then parsed using JsonSchema. Since ajv uses function constructors, it wouldn't be usable for this. However, falling back to the built-in JsonSchema is not really that bad, since the schemas it's validating are very small.