Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tools: make metadata parsing less permissive #19512

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 8 additions & 11 deletions tools/doc/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,31 +13,28 @@ function arrify(value) {
}

function extractAndParseYAML(text) {
text = text.trim();

text = text.replace(/^<!-- YAML/, '')
text = text.trim()
.replace(/^<!-- YAML/, '')
.replace(/-->$/, '');

// js-yaml.safeLoad() throws on error
const meta = yaml.safeLoad(text);

const added = meta.added || meta.Added;
if (added) {
if (meta.added) {
// Since semver-minors can trickle down to previous major versions,
// features may have been added in multiple versions.
meta.added = arrify(added);
meta.added = arrify(meta.added);
}

const deprecated = meta.deprecated || meta.Deprecated;
if (deprecated) {
if (meta.deprecated) {
// Treat deprecated like added for consistency.
meta.deprecated = arrify(deprecated);
meta.deprecated = arrify(meta.deprecated);
}

meta.changes = meta.changes || [];
meta.changes.forEach((entry) => {
for (const entry of meta.changes) {
entry.description = entry.description.replace(/^\^\s*/, '');
});
}

return meta;
}
Expand Down