GithubHelp home page GithubHelp logo

mattcg / har-to-curl Goto Github PK

View Code? Open in Web Editor NEW
58.0 58.0 15.0 24 KB

Convert a HAR (HTTP Archive) object to a cURL command using JavaScript.

Home Page: http://mattcg.github.io/har-to-curl/

JavaScript 100.00%

har-to-curl's People

Contributors

lcorbasson avatar mattcg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  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  avatar  avatar

har-to-curl's Issues

Backslashes are removed from POST data

POST data is included in the curl commands, but it seems that backslashes are removed along the way. So what should be posted as

curl -d "{\"id\":1002,\"shares\":[{\"id\":2,\"share\":0.9},{\"id\":3,\"share\":0.1}]}" ....

comes out as

curl -d "{"id":1002,"shares":[{"id":2,"share":0.9},{"id":3,"share":0.1}]}"

Insufficient escaping may lead to command execution

Double Quotes in values are not escaped properly in the curl command line that is presented. Example:

{
  "log": {
    "version": "1.2",
    "pages": [
      {
        "startedDateTime": "2023-08-02T10:52:21.439Z",
        "id": "page_1",
        "title": "https://example.com/"
      }
    ],
    "entries": [
      {
        "_initiator": {
          "type": "other"
        },
        "request": {
          "method": "GET",
          "url": "https://example.com/",
          "httpVersion": "http/2.0",
          "headers": [
            {
              "name": "user-agent",
              "value": "Mozilla/5.0 iPh\";echo HALLO; sleep 5; \" "
            }
          ],
          "cookies": [],
          "queryString": [],
          "headersSize": -1,
          "bodySize": 0
        }
      }
    ]
  }
}

creates the command

curl -X GET -H "user-agent: Mozilla/5.0 iPh";echo HALLO; sleep 5; " " https://example.com/

which will execute curl, echo and sleep 5, but not fetch any URLs.

suggested fix: Use single quotes (') to escape all strings, replace existing single quotes with '\'', i.e. one single quote, followed by a backslash and two more single quotes.

Support postData.params

Hi!

The tool is great, but postData with a text field only is supported.

According to the HAR 1.2 specs parameters may be specified in params array instead of text.

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.