@@ -50,8 +50,8 @@ module.exports = createCoreController('api::restaurant.restaurant', ({ strapi })
5050
5151 // Method 3: Replacing a core action with proper sanitization
5252 async find (ctx ) {
53- const qp = await this .sanitizeParams (ctx);
54- const { results , pagination } = await strapi .service (api:: restaurant .restaurant ).find (qp );
53+ const sanitizedQueryParams = await this .sanitizeQuery (ctx);
54+ const { results , pagination } = await strapi .service (api:: restaurant .restaurant ).find (sanitizedQueryParams );
5555 const sanitizedResults = await this .sanitizeOutput (results, ctx);
5656
5757 return this .transformResponse (sanitizedResults, { pagination });
@@ -93,8 +93,8 @@ export default factories.createCoreController('api::restaurant.restaurant', ({ s
9393
9494 // Method 3: Replacing a core action with proper sanitization
9595 async find (ctx ) {
96- const qp = await this .sanitizeParams (ctx);
97- const { results , pagination } = await strapi .service (api:: restaurant .restaurant ).find (qp );
96+ const sanitizedQueryParams = await this .sanitizeQuery (ctx);
97+ const { results , pagination } = await strapi .service (api:: restaurant .restaurant ).find (sanitizedQueryParams );
9898 const sanitizedResults = await this .sanitizeOutput (results, ctx);
9999
100100 return this .transformResponse (sanitizedResults, { pagination });
@@ -178,7 +178,7 @@ When a new [content-type](/dev-docs/backend-customization/models#content-types)
178178### Sanitization in controllers
179179
180180::: warning
181- As of Strapi v4.7 .0 and greater it's strongly recommended you sanitize your incoming request query and parameters utilizing the new ` sanitizeParams ` function to prevent leaking of private data.
181+ As of Strapi v4.8 .0 and greater it's strongly recommended you sanitize your incoming request query and parameters utilizing the new ` sanitizeQuery ` function to prevent leaking of private data.
182182:::
183183
184184#### Sanitization when utilizing controller factories
@@ -187,7 +187,7 @@ Within the Strapi factories there are 2 functions exposed that can be used for s
187187
188188| Function Name | Parameters | Description |
189189| ------------------| ----------------------------| --------------------------------------------------------------------------------------|
190- | ` sanitizeParams ` | ` ctx ` | Sanitizes the request query |
190+ | ` sanitizeQuery ` | ` ctx ` | Sanitizes the request query |
191191| ` sanitizeOutput ` | ` entity ` /` entities ` , ` ctx ` | Sanitizes the output data where entity/entities should be an object or array of data |
192192| ` sanitizeInput ` | ` data ` , ` ctx ` | Sanitizes the input data |
193193
@@ -202,8 +202,8 @@ const { createCoreController } = require('@strapi/strapi').factories;
202202
203203module .exports = createCoreController (' api::restaurant.restaurant' , ({ strapi }) => ({
204204 async findOne (ctx ) {
205- const qp = await this .sanitizeParams (ctx);
206- const { results , pagination } = await strapi .service (api:: restaurant .restaurant ).find (qp );
205+ const sanitizedQueryParams = await this .sanitizeQuery (ctx);
206+ const { results , pagination } = await strapi .service (api:: restaurant .restaurant ).find (sanitizedQueryParams );
207207 const sanitizedResults = await this .sanitizeOutput (results, ctx);
208208
209209 return this .transformResponse (sanitizedResults, { pagination });
@@ -221,8 +221,8 @@ import { factories } from '@strapi/strapi';
221221
222222export default factories .createCoreController (' api::restaurant.restaurant' , ({ strapi }) => ({
223223 async findOne (ctx ) {
224- const qp = await this .sanitizeParams (ctx);
225- const { results , pagination } = await strapi .service (api:: restaurant .restaurant ).find (qp );
224+ const sanitizedQueryParams = await this .sanitizeQuery (ctx);
225+ const { results , pagination } = await strapi .service (api:: restaurant .restaurant ).find (sanitizedQueryParams );
226226 const sanitizedResults = await this .sanitizeOutput (results, ctx);
227227
228228 return this .transformResponse (sanitizedResults, { pagination });
@@ -258,9 +258,9 @@ const { contentAPI } = sanitize;
258258module .exports = {
259259 async findCustom (ctx ) {
260260 const contentType = strapi .contentType (' api::test.test' )
261- const qp = await contentAPI .params (ctx .query , contentType, ctx .state .auth )
261+ const sanitizedQueryParams = await contentAPI .params (ctx .query , contentType, ctx .state .auth )
262262
263- const entities = await strapi .entityService .findMany (contentType .uid , qp )
263+ const entities = await strapi .entityService .findMany (contentType .uid , sanitizedQueryParams )
264264
265265 return await contentAPI .output (entities, contentType, ctx .state .auth );
266266 }
@@ -279,9 +279,9 @@ const { contentAPI } = sanitize;
279279export default {
280280 async findCustom (ctx ) {
281281 const contentType = strapi .contentType (' api::test.test' )
282- const qp = await contentAPI .params (ctx .query , contentType, ctx .state .auth )
282+ const sanitizedQueryParams = await contentAPI .params (ctx .query , contentType, ctx .state .auth )
283283
284- const entities = await strapi .entityService .findMany (contentType .uid , qp )
284+ const entities = await strapi .entityService .findMany (contentType .uid , sanitizedQueryParams )
285285
286286 return await contentAPI .output (entities, contentType, ctx .state .auth );
287287 }
0 commit comments