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

fix(lib): polynomial redos routes #763

Merged
merged 3 commits into from
Oct 28, 2023
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion lib/spec/openapi/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ function normalizeUrl (url, serverUrls, stripBasePath) {

function resolveServerUrls (servers) {
const resolvedUrls = []
const findVariablesRegex = /{(.*?)}/g // As for OpenAPI v3 spec url variables are named in brackets, e.g. {foo}
const findVariablesRegex = /\{([^{}]+)\}/gu // As for OpenAPI v3 spec url variables are named in brackets, e.g. {foo}

servers = Array.isArray(servers) ? servers : []
for (const server of servers) {
Expand Down
2 changes: 1 addition & 1 deletion lib/util/generate-params-schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

const { matchParams } = require('./match-params')

const namePattern = /\{([^}]+)\}/
const namePattern = /\{([^{}]+)\}/u

function paramName (param) {
return param.replace(namePattern, (_, captured) => captured)
Expand Down
2 changes: 1 addition & 1 deletion lib/util/match-params.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict'

const paramPattern = /\{[^{}]+\}/g
const paramPattern = /\{[^{}]+\}/gu

function hasParams (url) {
if (!url) return false
Expand Down