brenden / node-webshot

Easy website screenshots in Node.js
2.12k stars 285 forks source link

webshot fails when specifiying userAgent string with parens #72

Closed m90 closed 6 years ago

m90 commented 10 years ago

As soon as I'm passing a real UA string containing ( and ) to webshot's options webshot will fail.

My options look like:

{
    screenSize: {
        width: 320
        , height: 480
    }
    , shotSize: {
        width: 320
        , height: 'all'
    }
    , userAgent: 'Mozilla/5.0 (iPhone; U; CPU iPhone OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.20 (KHTML, like Gecko) Mobile/7B298g'
}

The error message I am seeing is the following:

c:\Users\me\my-project>  "c:\Users\me\AppData\Roaming\npm\\node.exe"  "c:\Users\me\AppData\Roaming\npm\\node_modules\phantomjs\bin\phantomjs" c:\Users\me\my-project\node_modules\webshot\lib/webshotphantom.js http://my.url.com c:\Users\me\my-project/screencaptures/2014-07-29/my-target-file.jpg false "{\"windowSize\":{\"width\":320,\"height\":480},\"shotSize\":{\"width\":320,\"height\":\"all\",\"shotOffset\":{\"left\":0,\"right\":0,\"top\":0,\"bottom\":0},\"streamType\":\"png\",\"siteType\":\"url\",\"quality\":75,\"settings\":{\"userAgent\":\"Mozilla5.0 (iPhone; U; CPU iPhone OS 3_2 like Mac OS X; en-us) AppleWebKit531.21.20 (KHTML, like Gecko) Mobile7B298g\"}}"

When I omit the userAgent option it will work like a charm. Even stranger: When I remove the parens from the passed string like:

Mozilla/5.0 iPhone; U; CPU iPhone OS 3_2 like Mac OS X; en-us AppleWebKit/531.21.20 KHTML, like Gecko Mobile/7B298g

it will work too.

My setup: Windows 8 Node 0.10.22 PhantomJS 1.9.7 Webshot 0.15.0