Commit 87cf0f9
committed
fix(fromJSONSchema): normalize input via JSON round-trip
`fromJSONSchema` previously stack-overflowed on cyclic JS object inputs
(e.g. dereferenced JSON Schemas where `$ref` strings have been replaced
with live object references) and on inputs with infinite-loop-on-access
getters or Proxies. JSON Schema is JSON, and JSON has no cycles — these
inputs are off-spec.
Round-trip the input through `JSON.parse(JSON.stringify(...))` at the
top of `fromJSONSchema`. Cyclic and otherwise non-JSON inputs throw a
clear error. Getter/Proxy properties are materialized into static values
and class instances collapse to plain objects, so the rest of the
converter only ever walks a finite, plain object graph.
Closes #5675.1 parent c7a8ccc commit 87cf0f9
2 files changed
Lines changed: 69 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
632 | 632 | | |
633 | 633 | | |
634 | 634 | | |
635 | | - | |
636 | | - | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
637 | 648 | | |
638 | 649 | | |
639 | 650 | | |
640 | 651 | | |
641 | 652 | | |
642 | 653 | | |
643 | | - | |
| 654 | + | |
644 | 655 | | |
645 | 656 | | |
646 | 657 | | |
647 | | - | |
| 658 | + | |
648 | 659 | | |
Lines changed: 54 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
839 | 839 | | |
840 | 840 | | |
841 | 841 | | |
| 842 | + | |
| 843 | + | |
| 844 | + | |
| 845 | + | |
| 846 | + | |
| 847 | + | |
| 848 | + | |
| 849 | + | |
| 850 | + | |
| 851 | + | |
| 852 | + | |
| 853 | + | |
| 854 | + | |
| 855 | + | |
| 856 | + | |
| 857 | + | |
| 858 | + | |
| 859 | + | |
| 860 | + | |
| 861 | + | |
| 862 | + | |
| 863 | + | |
| 864 | + | |
| 865 | + | |
| 866 | + | |
| 867 | + | |
| 868 | + | |
| 869 | + | |
| 870 | + | |
| 871 | + | |
| 872 | + | |
| 873 | + | |
| 874 | + | |
| 875 | + | |
| 876 | + | |
| 877 | + | |
| 878 | + | |
| 879 | + | |
| 880 | + | |
| 881 | + | |
| 882 | + | |
| 883 | + | |
| 884 | + | |
| 885 | + | |
| 886 | + | |
| 887 | + | |
| 888 | + | |
| 889 | + | |
| 890 | + | |
| 891 | + | |
| 892 | + | |
| 893 | + | |
| 894 | + | |
| 895 | + | |
0 commit comments