fix: crash when $ref is url encoded

reported by @mikunn
This commit is contained in:
Roman Hotsiy 2017-11-23 16:08:39 +02:00
parent 343f51a867
commit bdf60794f3
No known key found for this signature in database
GPG Key ID: 5CB7B3ACABA57CB0
3 changed files with 5 additions and 4 deletions

View File

@ -82,7 +82,7 @@
"json-schema-ref-parser": "^3.3.1", "json-schema-ref-parser": "^3.3.1",
"mobx": "^3.3.0", "mobx": "^3.3.0",
"mobx-react": "^4.3.3", "mobx-react": "^4.3.3",
"openapi-sampler": "^1.0.0-beta.1", "openapi-sampler": "1.0.0-beta.8",
"prismjs": "^1.8.1", "prismjs": "^1.8.1",
"prop-types": "^15.6.0", "prop-types": "^15.6.0",
"react-dropdown": "^1.3.0", "react-dropdown": "^1.3.0",

View File

@ -89,6 +89,7 @@ export class OpenAPIParser {
let res; let res;
if (this.spec === undefined) return; if (this.spec === undefined) return;
if (ref.charAt(0) !== '#') ref = '#' + ref; if (ref.charAt(0) !== '#') ref = '#' + ref;
ref = decodeURI(ref);
try { try {
res = JsonPointer.get(this.spec, decodeURIComponent(ref)); res = JsonPointer.get(this.spec, decodeURIComponent(ref));
} catch (e) { } catch (e) {

View File

@ -4670,9 +4670,9 @@ ono@^4.0.2:
dependencies: dependencies:
format-util "^1.0.3" format-util "^1.0.3"
openapi-sampler@^1.0.0-beta.1: openapi-sampler@1.0.0-beta.8:
version "1.0.0-beta.7" version "1.0.0-beta.8"
resolved "https://registry.yarnpkg.com/openapi-sampler/-/openapi-sampler-1.0.0-beta.7.tgz#4932a3994067af86f95cb912ee56d01123e27d88" resolved "https://registry.yarnpkg.com/openapi-sampler/-/openapi-sampler-1.0.0-beta.8.tgz#bf43ff47737fc4e1f988d0e2082d49788f41dead"
dependencies: dependencies:
json-pointer "^0.6.0" json-pointer "^0.6.0"