diff --git a/.gitignore b/.gitignore index 6709c76..9fe4328 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,4 @@ -google.pdf -yahoo.pdf +*.pdf tests/shoflo.js shoflo.js -google2.pdf -html.pdf node_modules diff --git a/render.js b/render.js index 2d06bd0..ce6f4af 100644 --- a/render.js +++ b/render.js @@ -13,7 +13,11 @@ if (phantom.args.length < 2) { console.log('incorrect args'); phantom.exit(); } else { - var options = JSON.parse(phantom.args[2]); + var optionsStr = phantom.args[2]; + // fix various escapings + optionsStr = optionsStr.replace(/\\!/g, '!'); // fix escaping of exclamation mark + optionsStr = optionsStr.replace(/\\\\"/g, '\\"'); // fix double escape of quot chars + var options = JSON.parse(optionsStr); contentsCb(options.paperSize.header); contentsCb(options.paperSize.footer); diff --git a/tests/pdf.js b/tests/pdf.js index 54d4411..267b1c9 100644 --- a/tests/pdf.js +++ b/tests/pdf.js @@ -56,7 +56,29 @@ describe('pdf#content', function() { assert.ok(false); d(); }); - }) + }); + + it('fixes shell escaping in content', function(d){ + this.timeout(5000); + var args = { content: '
' };
+ var pdf = new Pdf(null, 'html3.pdf', args);
+ pdf.on('done', function(file){
+ assert.equal(FP + '/html3.pdf', file);
+ d();
+ });
+
+ });
});
describe('pdf#done() 2', function(){