mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-03 12:04:05 +00:00
fix(schema): reject noncanonical array refs
This commit is contained in:
@@ -313,6 +313,13 @@ describe("schema validator", () => {
|
||||
$ref: "#/$defs/Missing",
|
||||
},
|
||||
],
|
||||
[
|
||||
"schema-validator.test.invalid-array-ref-leading-zero",
|
||||
{
|
||||
anyOf: [{ type: "number" }, { type: "string" }],
|
||||
$ref: "#/anyOf/01",
|
||||
},
|
||||
],
|
||||
[
|
||||
"schema-validator.test.invalid-dynamic-ref-type",
|
||||
{
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { Compile } from "typebox/compile";
|
||||
import type { JsonSchemaObject } from "./json-schema.types.js";
|
||||
import { parseConfigPathArrayIndex } from "./path-array-index.js";
|
||||
|
||||
type JsonSchemaValue = JsonSchemaObject | boolean;
|
||||
type LocalRefResolution =
|
||||
@@ -304,8 +305,8 @@ function resolveLocalRef(
|
||||
let currentResourceBaseId = resourceBaseId;
|
||||
for (const segment of ref.slice(2).split("/").map(decodePointerSegment)) {
|
||||
if (Array.isArray(current)) {
|
||||
const index = Number(segment);
|
||||
if (!Number.isInteger(index) || index < 0) {
|
||||
const index = parseConfigPathArrayIndex(segment);
|
||||
if (index === undefined) {
|
||||
return { found: false };
|
||||
}
|
||||
current = current[index];
|
||||
|
||||
Reference in New Issue
Block a user