Created
February 16, 2015 12:15
-
-
Save zaro/788a8fee8244d4ffc6f9 to your computer and use it in GitHub Desktop.
v0.12.0 segmentation fault in new Buffer(string, encoding)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var binding ; | |
try { | |
//binding = require('./build/Release/htmlstrip.node') | |
} catch(e){ | |
//binding = require('./build/Debug/htmlstrip.node') | |
} | |
module.exports.html_strip = function(html,options){ | |
var input; | |
if (typeof html == 'string'){ | |
input = new Buffer(html,'utf-16le'); | |
} else { | |
input = html; | |
} | |
console.log("sdfsd\n\n\n\n\n"); | |
console.log("sdfsd"); | |
console.log("sdfsd"); | |
return input.toString(); | |
//var buf = binding.html_strip(input, input.length, options); | |
//return buf.toString('utf-16le',0,buf._charsWritten*2); | |
} | |
module.exports.html_strip_with_hints = function(html,options){ | |
var input; | |
if (typeof html == 'string'){ | |
input = new Buffer(html,'utf-16le'); | |
} else { | |
input = html; | |
} | |
var buf = binding.html_strip(input, input.length, options); | |
return { | |
text: buf.toString('utf-16le',0,buf._charsWritten*2), | |
hints: buf.tag_hints | |
}; | |
} | |
module.exports.html_entities_decode = function(string){ | |
if (typeof string == 'string'){ | |
string = new Buffer(string,'utf-16le'); | |
} | |
var buf = binding.html_entities_decode(string, string.length); | |
return buf.toString('utf-16le',0,buf._charsWritten*2); | |
} | |
module.exports.accented_chars_norm = function(string){ | |
if (typeof string == 'string'){ | |
string = new Buffer(string,'utf-16le'); | |
} | |
var buf = binding.accented_chars_norm(string, string.length); | |
return buf.toString('utf-16le',0,buf._charsWritten*2); | |
} | |
module.exports.accented_chars_strip = function(string){ | |
if (typeof string == 'string'){ | |
string = new Buffer(string,'utf-16le'); | |
} | |
var buf = binding.accented_chars_strip(string, string.length); | |
return buf.toString('utf-16le',0,buf._charsWritten*2); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var hs = require('../') | |
var strings = { | |
'<a href="#"> linky link </a>' : ' linky link ', | |
'Á Ä = Ä | Ä = Ä| Ångström': 'Á Ä = Ä | Ä = Ä| Ångström', | |
'&&≈' : '&&≈', | |
'Begin <img src="some_url" alt="This should be \'in\' the output"> End' : "Begin This should be 'in' the output End", | |
'Begin <img src="some_url" alt=OnlyThis should be in the output> End': 'Begin OnlyThis End', | |
"Begin <img src=\"some_url\" alt='single\"_\"quoted'> End": 'Begin single"_"quoted End', | |
"Begin <img src=\"some_url\" alt='single> End" :'Begin single End' | |
}; | |
for(var i in strings){ | |
console.log(i); | |
var converted = hs.html_strip(i, {include_attributes:{'alt':true}}); | |
console.log(converted); | |
var result = (strings[i] == converted); | |
//console.log("done ......."); | |
if(!result){ | |
console.log( | |
"'" + i + "' : '" + strings[i] + "' ? " + | |
"'" + strings[i] + "' == '" + converted + "' -> '" + | |
result + "'" | |
); | |
console.log('FAIL!'); | |
process.exit(-1); | |
} | |
} | |
console.log('OK'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment