Git Product home page Git Product logo

Comments (8)

lewisdiamond avatar lewisdiamond commented on June 8, 2024

If you are interested, I will fork your repo, fix a few things and make a pull request so that you can distribute my changes.

Let me know.

from reqwest.

ded avatar ded commented on June 8, 2024

eval is not bad if it's your own website and data

from reqwest.

lewisdiamond avatar lewisdiamond commented on June 8, 2024

This is no response. Eval is bad even if it's your own website and data.

Consider a website sending data to the backend service and the service including the request or part of it in the response in order to be processed on the UI side. Someone malicious could forge a request that could end up being evaluated if proper care wasn't taken (i.e. making sure reqwest won't eval and encoding everything that came from the user). Browse around, there are tons of such websites. Using eval adds a risk for cross-site scripting.

Think about it.

from reqwest.

rvagg avatar rvagg commented on June 8, 2024

If you're using JSON responses, just make sure you have a window.JSON object, use a polyfill for older browsers, and eval() won't be invoked. If you're using Reqwest in Ender then include ender-json in your build and the world will be at peace.

If you're using JS responses and don't like eval() then stop using JS or give it a different type and handle responseText yourself. JS over AJAX isn't ideal anyway.

from reqwest.

lewisdiamond avatar lewisdiamond commented on June 8, 2024

Oh, I'm definitely not sending JS from the server. I'm just stating the fact that code can be injected and executed through the eval().

from reqwest.

rvagg avatar rvagg commented on June 8, 2024

caveat emptor

from reqwest.

ded avatar ded commented on June 8, 2024

sorry if the response was terse. as @rvagg explained, there are simple ways around it and it's used as the last resort

from reqwest.

lewisdiamond avatar lewisdiamond commented on June 8, 2024

Oh I'm aware of the proper ways to do ajax. However, in your library, 'JS' is absolutely not "last resort" as your it uses it by DEFAULT. This is the complete opposite of last resort. Make the web safer by preventing inexperienced developers make silly mistakes like that.

If you feel the 'JS' type can be useful for some people, by all means keep it, but it should definitely not be the default. Furthermore, the 'JSON' type should not default to a simple 'eval()' call in case of a browser without native JSON parser (an alternative solution is use a JSON parser lib like crockford's).

There is a reason why JSON parsers exist in the first place.

This is my professional opinion. Take it or leave it.

from reqwest.

Related Issues (20)

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.