Skip to content

Commit

Permalink
fix(markdown): prevent unescaped objects in markdown AST
Browse files Browse the repository at this point in the history
makes sure that the `type` property is either a string or an array before passing it into the
Markdown AST

fixes #201
  • Loading branch information
trieloff committed Jan 20, 2020
1 parent d09a421 commit 87d709a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/locales/en_US.json
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@
"the string must be a JSON Pointer, according to ": "the string must be a JSON Pointer, according to ",
"the string must be a URI template, according to ": "the string must be a URI template, according to ",
"the string must be a regular expression, according to ": "the string must be a regular expression, according to ",
"the string must be a relative JSON Pointer, according to ": "the string must be a relative JSON Pointer, according to "
"the string must be a relative JSON Pointer, according to ": "the string must be a relative JSON Pointer, according to ",
"Unknown Type": "Unknown Type"
}
}
3 changes: 3 additions & 0 deletions lib/markdownBuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,9 @@ function build({
}

function type(property) {
if (typeof property[keyword`type`] === 'object') {
return text(i18n`Unknown Type`);
}
const types = Array.isArray(property[keyword`type`]) ? property[keyword`type`] : [property[keyword`type`]];
const realtypes = flist(filter(types, mytype => mytype !== 'null' && mytype !== undefined));
if (property[keyword`allOf`] || property[keyword`anyOf`] || property[keyword`oneOf`] || property[keyword`not`]) {
Expand Down

0 comments on commit 87d709a

Please sign in to comment.