Giter VIP home page Giter VIP logo

disinfect's People

Contributors

diego-deriv avatar ekawas avatar genediazjr avatar surgisonb avatar theinfinity007 avatar treenity avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

disinfect's Issues

Fix @hapi deprecations

The following deprecations are present:

warning disinfect > [email protected]: This version has been deprecated in accordance with the hapi support policy (hapi.im/support). Please upgrade to the latest version to get the best features, bug fixes, and security patches. If you are unable to upgrade at this time, paid support is available for older versions (hapi.im/commercial).
warning disinfect > [email protected]: This version has been deprecated in accordance with the hapi support policy (hapi.im/support). Please upgrade to the latest version to get the best features, bug fixes, and security patches. If you are unable to upgrade at this time, paid support is available for older versions (hapi.im/commercial).
warning disinfect > joi > [email protected]: This version has been deprecated in accordance with the hapi support policy (hapi.im/support). Please upgrade to the latest version to get the best features, bug fixes, and security patches. If you are unable to upgrade at this time, paid support is available for older versions (hapi.im/commercial).
warning disinfect > joi > [email protected]: This module has moved and is now available at @hapi/topo. Please update your dependencies as this version is no longer maintained an may contain bugs and security issues.
warning disinfect > joi > topo > [email protected]: This module has moved and is now available at @hapi/hoek. Please update your dependencies as this version is no longer maintained an may contain bugs and security issues.```

disinfectPayload cast all my arrays into strings

Hi,

I was testing this plugin to sanitize my payload. However is seems like any array contained in my payload is cast into a string.
Example payload :
{ "text1": "test a", "text2": "test b", "array": [ { "text3": "test c", "text4": "test d" }, { "text3": "test e", "text4": "test f" } ] }

Result :
{"text1":"test a","text2":"test b","array":"[object Object],[object Object]"}

Disinfect giving "TypeError: Cannot assign to read only property '0' of string" during sanitation

I am using hapi server and I want to use joi header validation( for content-type: 'application/json') in my PUT method.

The problem comes when the user sends a valid json in payload and sends 'content-type' header with value 'text/css' or 'text/javascript'. On postAuth this payload as a stringified string goes to disinfect and it is throwing error.

TypeError: Cannot assign to read only property '0' of string

Because of this the request in not reaching to the joi validation, which is present at the route level.

It can be one of the edge cases. Ideally the purpose of disinfect is the sanitation of the request data and should not throw error.

I am also attaching the request curl

curl --location --request PUT 'http://localhost:3000/blogs/b1' \ --header 'Content-Type: text/css' \ --data-raw '{ "text1": "test a", "text2": "test b" }'

"error": { "code": "Internal Server Error", "message": "An internal server error occurred", "statusCode": 500, "trace": "TypeError: Cannot assign to read only property '0' of string '{ \"text1\": \"test a\", \"text2\": \"test b\" }'\n at Object.internals.sanitize (/Users/infinity/Desktop/myAppService/node_modules/disinfect/lib/index.js:37:26)\n at Object.internals.disinfect (/Users/infinity/Desktop/myAppService/node_modules/disinfect/lib/index.js:75:34)\n at /Users/infinity/Desktop/myAppService/node_modules/disinfect/lib/index.js:137:45\n at exports.Manager.execute (/Users/infinity/Desktop/myAppService/node_modules/@hapi/hapi/lib/toolkit.js:57:29)\n at Request._invoke (/Users/infinity/Desktop/myAppService/node_modules/@hapi/hapi/lib/request.js:391:55)\n at Request._lifecycle (/Users/infinity/Desktop/myAppService/node_modules/@hapi/hapi/lib/request.js:364:86)\n at processTicksAndRejections (internal/process/task_queues.js:97:5)\n at async Request._execute (/Users/infinity/Desktop/myAppService/node_modules/@hapi/hapi/lib/request.js:273:9)" }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.