Code Monkey home page Code Monkey logo

libxml-to-js's People

Contributors

kysnm avatar marsup avatar richardanaya avatar saltwaterc avatar virgiled 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

Watchers

 avatar  avatar  avatar  avatar

libxml-to-js's Issues

Entities remain in output object text

In certain cases, the entities <, >, and & appear in the output object. This seems to occur only when they are in the element text and there are no attributes on the element. Numeric versions (decimal or hexadecimal) of these entities are affected too.

Simple example:

> libxmlToJs("<root><example>TEST &lt; TEST</example></root>", function(error, result) { console.info(JSON.stringify(result)); });
{"example":"TEST &lt; TEST"}

It is handled correctly if there is any attribute on the element:

> libxmlToJs("<root><example attr='000'>TEST &lt; TEST</example></root>", function(error, result) { console.info(JSON.stringify(result)); });
{"example":{"@":{"attr":"000"},"#":"TEST < TEST"}}

Numeric entity also fails (note that it appears as &lt; in the output:

> libxmlToJs("<root><example>TEST &#60; TEST</example></root>", function(error, result) { console.info(JSON.stringify(result)); });
{"example":"TEST &lt; TEST"}

Characters apart from < > & work correctly:

> libxmlToJs("<root><example>TEST &lt; &gt; &amp; &apos; &quot; &#65; &#x41; TEST</example></root>", function(error, result) { console.info(JSON.stringify(result)); });
{"example":"TEST &lt; &gt; &amp; ' \" A A TEST"}

Thank you!

Failed to install with npm

I'm trying to install with npm install -d (as dependecy on package.json):

npm ERR! [email protected] install: `node-waf configure build`
npm ERR! `sh "-c" "node-waf configure build"` failed with 1
npm ERR! 
npm ERR! Failed at the [email protected] install script.
npm ERR! This is most likely a problem with the libxmljs package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-waf configure build
npm ERR! You can get their info via:
npm ERR!     npm owner ls libxmljs
npm ERR! There is likely additional logging output above.

npm ERR! System Linux 3.2.0-26-generic
npm ERR! command "node" "/usr/bin/npm" "install" "-d"
npm ERR! cwd /home/exos/alpha/xxxxx/node-xxxxx-api
npm ERR! node -v v0.8.1
npm ERR! npm -v 1.1.35
npm ERR! code ELIFECYCLE
npm ERR! message [email protected] install: `node-waf configure build`
npm ERR! message `sh "-c" "node-waf configure build"` failed with 1
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /home/exos/alpha/xxxxx/node-xxxx-api/npm-debug.log
npm ERR! not ok code 0

If i try, directly npm install libxml-to-js I can see the error:

[exos@Hexodica node-xxxxx-api]$ npm install libxml-to-js
npm http GET https://registry.npmjs.org/libxml-to-js
npm http 304 https://registry.npmjs.org/libxml-to-js
npm http GET https://registry.npmjs.org/libxmljs
npm http 304 https://registry.npmjs.org/libxmljs

> [email protected] install /home/exos/alpha/xxxxx/node-xxxxx-api/node_modules/libxml-to-js/node_modules/libxmljs
> node-waf configure build

Checking for program g++ or c++          : /usr/bin/g++ 
Checking for program cpp                 : /usr/bin/cpp 
Checking for program ar                  : /usr/bin/ar 
Checking for program ranlib              : /usr/bin/ranlib 
Checking for g++                         : ok  
Checking for node path                   : not found 
Checking for node prefix                 : ok /usr 
Checking for program xml2-config         : not found 
/home/exos/alpha/xxxxx/node-xxxxx-api/node_modules/libxml-to-js/node_modules/libxmljs/wscript:15: error: The program ['xml2-config'] is required

I, solved this installing the Ubutnu package libxml2-dev

sudo apt-get install libxml2-dev

You can avoid many headaches by specifying this in the documentation.

PD: Sorry my English.

Library does not read CDATA sections

For example from string <phrase section="default" code="widgethome"><![CDATA[Home]]></phrase> only attributes are read, resulting object does not have '#' property.

Fails to build on Fedora 16/x86_64

Using Fedora build of nodejs


> [email protected] preinstall /usr/lib/node_modules/libxml-to-js/node_modules/libxmljs
> make node

scons: Reading SConscript files ...
Checking for node.js ...(cached) yes
True
Checking for C++ library xml2... yes
Checking for node.js ...(cached) yes
scons: done reading SConscript files.
scons: Building targets ...
g++ -o src/html_document.os -c -I/usr/include/libxml2 -g -O3 -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -rdynamic -D__POSIX__=1 -DHAVE_FDATASYNC=1 -DPLATFORM="linux" -DX_STACKSIZE=65536 -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DEV_MULTIPLICITY=1 -D_FORTIFY_SOURCE=2 -DHAVE_CONFIG_H=1 -DHAVE_OPENSSL=1 -I/usr/include/node -fPIC src/html_document.cc
In file included from src/html_document.h:5:0,
                 from src/html_document.cc:2:
src/libxmljs.h:6:18: fatal error: node.h: No such file or directory
compilation terminated.
scons: **\* [src/html_document.os] Error 1
scons: building terminated because of errors.
make: **\* [node] Error 2
npm ERR! error installing [email protected] Error: [email protected] preinstall: `make node`
npm ERR! error installing [email protected] `sh "-c" "make node"` failed with 2
npm ERR! error installing [email protected]     at ChildProcess.<anonymous> (/usr/lib/node_modules/npm/lib/utils/exec.js:49:20)
npm ERR! error installing [email protected]     at ChildProcess.emit (events.js:67:17)
npm ERR! error installing [email protected]     at ChildProcess.onexit (child_process.js:192:12)

> [email protected] preuninstall /usr/lib/node_modules/libxml-to-js/node_modules/libxmljs
> make clean

scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Cleaning targets ...
scons: done cleaning targets.
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Cleaning targets ...
scons: done cleaning targets.
npm ERR! error installing [email protected] Error: [email protected] preinstall: `make node`
npm ERR! error installing [email protected] `sh "-c" "make node"` failed with 2
npm ERR! error installing [email protected]     at ChildProcess.<anonymous> (/usr/lib/node_modules/npm/lib/utils/exec.js:49:20)
npm ERR! error installing [email protected]     at ChildProcess.emit (events.js:67:17)
npm ERR! error installing [email protected]     at ChildProcess.onexit (child_process.js:192:12)
npm ERR! [email protected] preinstall: `make node`
npm ERR! `sh "-c" "make node"` failed with 2
npm ERR! 
npm ERR! Failed at the [email protected] preinstall script.
npm ERR! This is most likely a problem with the libxmljs package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     make node
npm ERR! You can get their info via:
npm ERR!     npm owner ls libxmljs
npm ERR! There is likely additional logging output above.
npm ERR! 
npm ERR! System Linux 3.0.0-1.fc16.x86_64
npm ERR! command "node" "/usr/bin/npm" "install" "-g" "libxml-to-js"
npm ERR! cwd /root
npm ERR! node -v v0.4.11
npm ERR! npm -v 1.0.26
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /root/npm-debug.log
npm not ok
[root@bradford ~]# ```

Error Handling

I'm just wondering why you execute the xml parsing/callback inside of a try block and then catch it with:

} catch (err) {
    err.message = err.message || 'libxml error';
    var errInst = new Error(err.message);
    errInst.code = err.code || 0;
    callback(errInst);
}

err contains a stack trace which is very valuable for debugging (at least when the user of the library throws an error after converting xml to js). However, the stack trace is lost in this catch block when transferring properties of err to errInst. What's wrong with doing

} catch (err) {
  err.message = err.message || 'libxml error';
  err.code = err.code || 0;
  callback(err);
}

?

Install on ARM platform

Hi,

I wanted to install this on a BeagleBone. Angstrom v2012.01-core - Kernel 3.2.5+
The build throws errors, apparently a missing dependency.
Not sure if this would be difficult to fix or if there's anything I can do to help.
BTW. NPM seems to work on some modules and not others.

Paul

root@beaglebone:/var/lib/cloud9# npm install libxml-to-js

[email protected] install /var/lib/cloud9/node_modules/libxml-to-js/node_modules/libxmljs
node-waf configure build

Checking for program g++ or c++ : /usr/bin/g++
Checking for program cpp : /usr/bin/cpp
Checking for program ar : /usr/bin/ar
Checking for program ranlib : /usr/bin/ranlib
Checking for g++ : ok
Checking for node path : not found
Checking for node prefix : ok /usr
Checking for program xml2-config : /usr/bin/xml2-config
'configure' finished successfully (2.208s)
Waf: Entering directory /var/lib/cloud9/node_modules/libxml-to-js/node_modules/libxmljs/build' [ 1/10] cxx: src/libxmljs.cc -> build/default/src/libxmljs_1.o [ 2/10] cxx: src/xml_attribute.cc -> build/default/src/xml_attribute_1.o [ 3/10] cxx: src/xml_document.cc -> build/default/src/xml_document_1.o [ 4/10] cxx: src/xml_element.cc -> build/default/src/xml_element_1.o [ 5/10] cxx: src/xml_namespace.cc -> build/default/src/xml_namespace_1.o [ 6/10] cxx: src/xml_node.cc -> build/default/src/xml_node_1.o ../src/xml_node.cc: In member function 'v8::Handle<v8::Value> libxmljs::XmlNode::get_type()': ../src/xml_node.cc:335:8: error: 'XML_DOCB_DOCUMENT_NODE' was not declared in this scope Waf: Leaving directory/var/lib/cloud9/node_modules/libxml-to-js/node_modules/libxmljs/build'
Build failed: -> task failed (err #1):
{task: cxx xml_node.cc -> xml_node_1.o}
npm ERR! error installing [email protected] Error: [email protected] install: node-waf configure build
npm ERR! error installing [email protected] sh "-c" "node-waf configure build" failed with 1
npm ERR! error installing [email protected] at ChildProcess. (/usr/lib/node_modules/npm/lib/utils/exec.js:49:20)
npm ERR! error installing [email protected] at ChildProcess.emit (events.js:67:17)
npm ERR! error installing [email protected] at ChildProcess.onexit (child_process.js:192:12)

[email protected] preuninstall /var/lib/cloud9/node_modules/libxml-to-js/node_modules/libxmljs
node-waf clean

'clean' finished successfully (0.064s)
npm ERR! error installing [email protected] Error: [email protected] install: node-waf configure build
npm ERR! error installing [email protected] sh "-c" "node-waf configure build" failed with 1
npm ERR! error installing [email protected] at ChildProcess. (/usr/lib/node_modules/npm/lib/utils/exec.js:49:20)
npm ERR! error installing [email protected] at ChildProcess.emit (events.js:67:17)
npm ERR! error installing [email protected] at ChildProcess.onexit (child_process.js:192:12)
npm ERR! [email protected] install: node-waf configure build
npm ERR! sh "-c" "node-waf configure build" failed with 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is most likely a problem with the libxmljs package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-waf configure build
npm ERR! You can get their info via:
npm ERR! npm owner ls libxmljs
npm ERR! There is likely additional logging output above.
npm ERR!
npm ERR! System Linux 3.2.5+
npm ERR! command "node" "/usr/bin/npm" "install" "libxml-to-js"
npm ERR! cwd /var/lib/cloud9
npm ERR! node -v v0.4.12
npm ERR! npm -v 1.0.106
npm ERR! code ELIFECYCLE
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /var/lib/cloud9/npm-debug.log
npm not ok

CData

Doesn't differentiate between CDATA and a plain text node (that I could find). Important for parsing RSS.

Error on unstable branch of node (v0.11.7)

Hi, just for your information.
When I trying libxml-to-js on unstable node, get this error:

/home/stonedmind/Workspace/Projects/geekwears/node_modules/libxml-to-js/node_modules/libxmljs/node_modules/bindings/bindings.js:79
        throw e
              ^
Error: /home/stonedmind/Workspace/Projects/geekwears/node_modules/libxml-to-js/node_modules/libxmljs/build/Release/xmljs.node: undefined symbol: _ZN2v82V837AdjustAmountOfExternalAllocatedMemoryEl
    at Module.load (module.js:349:32)
    at Function.Module._load (module.js:305:12)
    at Module.require (module.js:357:17)
    at require (module.js:373:17)
    at bindings (/home/stonedmind/Workspace/Projects/geekwears/node_modules/libxml-to-js/node_modules/libxmljs/node_modules/bindings/bindings.js:74:15)
    at Object.<anonymous> (/home/stonedmind/Workspace/Projects/geekwears/node_modules/libxml-to-js/node_modules/libxmljs/lib/bindings.js:1:99)
    at Module._compile (module.js:449:26)
    at Object.Module._extensions..js (module.js:467:10)
    at Module.load (module.js:349:32)
    at Function.Module._load (module.js:305:12)

Node12 issues

Hi,
Do you have plans to support node12 ?
I can understand its an issue with the base lib but wonder if you are thinking about it or can suggest a workaround.

Fails to install via npm

Using node v0.4.12 on OSX 10.7, after executing npm install libxml-to-js I get the below error:

npm WARN [email protected] package.json: bugs['web'] should probably be bugs['url']
npm WARN [email protected] package.json: bugs['web'] should probably be bugs['url']

[email protected] preinstall /Users/billc/Applications/github-hubot-3980db0/node_modules/libxmljs
make node

make: scons: No such file or directory
make: *** [node] Error 1
npm ERR! error installing [email protected] Error: [email protected] preinstall: make node
npm ERR! error installing [email protected] sh "-c" "make node" failed with 2
npm ERR! error installing [email protected] at ChildProcess. (/usr/local/lib/node_modules/npm/lib/utils/exec.js:49:20)
npm ERR! error installing [email protected] at ChildProcess.emit (events.js:67:17)
npm ERR! error installing [email protected] at ChildProcess.onexit (child_process.js:192:12)

[email protected] preuninstall /Users/billc/Applications/github-hubot-3980db0/node_modules/libxmljs
make clean

make: scons: No such file or directory
make: *** [clean] Error 1
npm WARN continuing anyway [email protected] preuninstall: make clean
npm WARN continuing anyway sh "-c" "make clean" failed with 2
npm ERR! [email protected] preinstall: make node
npm ERR! sh "-c" "make node" failed with 2
npm ERR!
npm ERR! Failed at the [email protected] preinstall script.
npm ERR! This is most likely a problem with the libxmljs package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! make node
npm ERR! You can get their info via:
npm ERR! npm owner ls libxmljs
npm ERR! There is likely additional logging output above.
npm ERR!
npm ERR! System Darwin 11.2.0
npm ERR! command "node" "/usr/local/bin/npm" "install" "libxmljs"
npm ERR! cwd /Users/billc/Applications/github-hubot-3980db0
npm ERR! node -v v0.4.12
npm ERR! npm -v 1.0.103
npm ERR! code ELIFECYCLE
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /Users/billc/Applications/github-hubot-3980db0/npm-debug.log
npm not ok

I have libxml2 installed via brew but no help. Any ideas on what is going wrong?

CRITICAL BUG: simple test case losing attribute name

var test = '<thing><real id="width">300</real><real id="height">200</real></thing>';
parser(test, function (error, result) {
    if (error) {
        console.error(error);
    }
    else {
        console.log(JSON.stringify(result,null,'  '));
    }
});

Segmentation fault

Hi there,

I'm using libxml-to-js in a node app and finding that I can consistently crash the XML parser -- though it doesn't look like the crash is coming from libxmljs because I can use that package with this XML and it doesn't cause a segmentation fault (though it doesn't parse at all).

Here's what I'm running in a node prompt:

> var parser = require('libxml-to-js');
> var xml = `<?xml version="1.0" encoding="ISO-8859-1"?>  <!DOCTYPE foo [ <!ELEMENT foo ANY > <!ENTITY xxe "DEMOTEXT" >]> <firstTag> <secondTag>&xxe;</secondTag></firstTag>`;
> parser(xml, function (error, result) {
... if (error) {
..... console.error(error);
..... } else {
..... console.log(result);
..... }
... });
Segmentation fault

This consistently results in a Segmentation fault.

However, if I use the libxmljs library directly, it just doesn't result in a parsed object, though no segmentation fault:

> var libxmljs = require("libxmljs");
> var xml = `<?xml version="1.0" encoding="ISO-8859-1"?>  <!DOCTYPE foo [ <!ELEMENT foo ANY > <!ENTITY xxe "DEMOTEXT" >]> <firstTag> <secondTag>&xxe;</secondTag></firstTag>`;
> var xmlDoc = libxmljs.parseXml(xml);
> xmlDoc
Document { errors: [] }

I'm using 0.3.12 and have tested it on 0.3.11 as well and am using node 8.8.1 locally as well as node 8.9.3 on my application server where it crashes as well. Am I doing something wrong here? Or is this a bug in libxml-to-js?

Thanks!

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.