From dabca0310472c27b2c983fc0b1136ba9893e6d94 Mon Sep 17 00:00:00 2001 From: adon Date: Fri, 16 Oct 2015 18:56:17 +0800 Subject: [PATCH 1/2] added canonicalizr utility --- bin/canonicalizr.js | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100755 bin/canonicalizr.js diff --git a/bin/canonicalizr.js b/bin/canonicalizr.js new file mode 100755 index 0000000..1bface0 --- /dev/null +++ b/bin/canonicalizr.js @@ -0,0 +1,26 @@ +#!/usr/bin/env node +/* +Copyright (c) 2015, Yahoo! Inc. All rights reserved. +Copyrights licensed under the New BSD License. +See the accompanying LICENSE file for terms. +*/ + +var fs = require('fs'), + Canonicalizr = require('../src/context-parser').Parser; + +if (process.argv.length !== 3) { + console.log("Usage: canonicalizr filePath"); + process.exit(1); +} + +var html = fs.readFileSync(process.argv[2], "utf8"); +var c = new Canonicalizr({ + enableCanonicalization: false, + enableVoidingIEConditionalComments: false, + enableStateTracking: false +}); + +// do not use console.log(), which append an unnecessary linebreak +// console.log() in nodejs v0.12 or below are vulnerable to eat % +// ref: https://github.com/nodejs/node/issues/3396 +process.stdout.write(c.contextualize(html)); \ No newline at end of file From 400f3f8f7780d3cacf50801dfb0e245d56696136 Mon Sep 17 00:00:00 2001 From: adon Date: Tue, 20 Oct 2015 13:35:27 +0900 Subject: [PATCH 2/2] Enable canonicalization by default --- bin/canonicalizr.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bin/canonicalizr.js b/bin/canonicalizr.js index 1bface0..f6ea933 100755 --- a/bin/canonicalizr.js +++ b/bin/canonicalizr.js @@ -15,12 +15,12 @@ if (process.argv.length !== 3) { var html = fs.readFileSync(process.argv[2], "utf8"); var c = new Canonicalizr({ - enableCanonicalization: false, - enableVoidingIEConditionalComments: false, + enableCanonicalization: true, + enableVoidingIEConditionalComments: true, enableStateTracking: false }); // do not use console.log(), which append an unnecessary linebreak // console.log() in nodejs v0.12 or below are vulnerable to eat % // ref: https://github.com/nodejs/node/issues/3396 -process.stdout.write(c.contextualize(html)); \ No newline at end of file +process.stdout.write(c.contextualize(html));