-
-
Notifications
You must be signed in to change notification settings - Fork 317
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 array query string parsing #5268
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import querystring from "querystring"; | ||
import qs from "qs"; | ||
import fastify, {FastifyError, FastifyInstance} from "fastify"; | ||
import fastifyCors from "fastify-cors"; | ||
import bearerAuthPlugin from "fastify-bearer-auth"; | ||
|
@@ -43,7 +43,15 @@ export class RestApiServer { | |
const server = fastify({ | ||
logger: false, | ||
ajv: {customOptions: {coerceTypes: "array"}}, | ||
querystringParser: querystring.parse, | ||
querystringParser: (str) => | ||
qs.parse(str, { | ||
// defaults to 20 but Beacon API spec allows max items of 30 | ||
arrayLimit: 30, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Beacon API spec defines |
||
// array as comma-separated values must be supported to be OpenAPI spec compliant | ||
comma: true, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. koa openapi req/res validator uses this library as well and sets |
||
// default limit of 1000 seems unnecessarily high, let's reduce it a bit | ||
parameterLimit: 100, | ||
}), | ||
bodyLimit: opts.bodyLimit, | ||
}); | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3406,10 +3406,10 @@ | |
resolved "https://registry.npmjs.org/@types/prometheus-gc-stats/-/prometheus-gc-stats-0.6.1.tgz" | ||
integrity sha512-tSj7MRNgEJCSqVRgPL4WIIcslZChgL6gVwnVFsAj2nTx0RdcG7iSpWm+0fkAKEe7e/YQ08TZH4wQWxpFODYqJw== | ||
|
||
"@types/qs@^6.9.6": | ||
version "6.9.6" | ||
resolved "https://registry.npmjs.org/@types/qs/-/qs-6.9.6.tgz" | ||
integrity sha512-0/HnwIfW4ki2D8L8c9GVcG5I72s9jP5GSLVF0VIXDW00kmIpA6O33G7a8n59Tmh7Nz0WUC3rSb7PTY/sdW2JzA== | ||
"@types/qs@^6.9.7": | ||
version "6.9.7" | ||
resolved "https://registry.yarnpkg.com/@types/qs/-/qs-6.9.7.tgz#63bb7d067db107cc1e457c303bc25d511febf6cb" | ||
nflaig marked this conversation as resolved.
Show resolved
Hide resolved
|
||
integrity sha512-FGa1F62FT09qcrueBA6qYTrJPVDzah9a+493+o2PCXsesWHIn27G98TsSMs3WPNbZIEj4+VJf6saSFpvD+3Zsw== | ||
|
||
"@types/readable-stream@*": | ||
version "2.3.11" | ||
|
@@ -10992,13 +10992,20 @@ [email protected]: | |
resolved "https://registry.yarnpkg.com/qs/-/qs-6.9.3.tgz#bfadcd296c2d549f1dffa560619132c977f5008e" | ||
integrity sha512-EbZYNarm6138UKKq46tdx08Yo/q9ZhFoAXAI1meAFd2GtbRDhbZY2WQSICskT0c5q99aFzLG1D4nvTk9tqfXIw== | ||
|
||
qs@^6.10.1, qs@^6.10.3: | ||
qs@^6.10.3: | ||
version "6.11.0" | ||
resolved "https://registry.yarnpkg.com/qs/-/qs-6.11.0.tgz#fd0d963446f7a65e1367e01abd85429453f0c37a" | ||
integrity sha512-MvjoMCJwEarSbUYk5O+nmoSzSutSsTwF85zcHPQ9OrlFoZOYIjaqBAJIqIXjptyD5vThxGq52Xu/MaJzRkIk4Q== | ||
dependencies: | ||
side-channel "^1.0.4" | ||
|
||
qs@^6.11.1: | ||
version "6.11.1" | ||
resolved "https://registry.yarnpkg.com/qs/-/qs-6.11.1.tgz#6c29dff97f0c0060765911ba65cbc9764186109f" | ||
integrity sha512-0wsrzgTz/kAVIeuxSjnpGC56rzYtr6JT/2BwEvMaPhFIoYa1aGO8LbzuU1R0uUYQkLpWBTOj0l/CLAJB64J6nQ== | ||
dependencies: | ||
side-channel "^1.0.4" | ||
|
||
querystring-es3@^0.2.0: | ||
version "0.2.1" | ||
resolved "https://registry.npmjs.org/querystring-es3/-/querystring-es3-0.2.1.tgz" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see default parse options