Code Monkey home page Code Monkey logo

node-base64's People

Contributors

brainpicture avatar d0k avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

node-base64's Issues

about binary decode

I've got strange results with JPEG headers, results are differents with php.

In PHP :
php -r 'file_put_contents("/tmp/blah", base64_decode("/9j/"));'
// hd /tmp/blah => 0xff 0xd8 0xff

In node-repl :
require('fs').writeFileSync('/tmp/blah', require('node-base64').decode('/9j/'),'binary');
// hd /tmp/blah => 0xfd 0xfd 0xfd

Does the problem comes from binary data decoding ?

Incorrect decoding - weird â characters

If you try to decode message.base64 in https://gist.github.com/763844 you get slightly wrong output. For example, "Itâ��s ghetto" is part of the decoded string, but it should be "It’s ghetto".

var encoded = require('fs').readFileSync(__dirname + '/message.base64', 'ascii');
console.log(require('base64').decode(encoded));

can't build on a OSX 10.6 Intel 32 bits

The build :

$ make
node-waf configure build && mkdir -p ~/.node_libraries && cp ./build/default/base64.node ~/.node_libraries/base64.node
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 program gcc or cc           : /usr/bin/gcc 
Checking for gcc                         : ok  
Checking for node path                   : ok /Users/mlecarme/.node_libraries 
Checking for node prefix                 : ok /usr/local/Cellar/node/0.1.103 
'configure' finished successfully (0.140s)
Waf: Entering directory `/private/tmp/node-base64/build'
Waf: Leaving directory `/private/tmp/node-base64/build'
'build' finished successfully (0.042s)

The test :

$ make tests
node ./test.js

module:328
  process.dlopen(filename, this.exports);
          ^
Error: dlopen(/private/tmp/node-base64/build/default/base64.node, 1): Symbol not found:    __ZN4node6Buffer20constructor_templateE
  Referenced from: /private/tmp/node-base64/build/default/base64.node
  Expected in: flat namespace
 in /private/tmp/node-base64/build/default/base64.node
    at Module._loadObjectSync (module:328:11)
    at Module.loadSync (module:304:10)
    at loadModule (module:251:12)
    at require (module:374:12)
    at Object.<anonymous> (/private/tmp/node-base64/test.js:1:76)
    at Module._compile (module:426:23)
    at Module._loadScriptSync (module:436:8)
    at Module.loadSync (module:306:10)
    at Object.runMain (module:490:22)
    at node.js:254:10
make: *** [tests] Error 11

Leaking memory

The other problem in your module is that it's leaking memory in base64_encode_binding. See, you are doing this:

unsigned char* str=base64_decode((unsigned char*)*data,data.length(),&len);

And then you:

return String::New((const char*)str,len);

But String::New constructs a new string from char *, it does not copy the pointer internally.

And before this you do:

result = (unsigned char *)malloc(length+1);

in base64_decode.

This pointer leaks!

My suggested fix:

Handle<Value>
base64_encode_binding(const Arguments& args)
{
  HandleScope scope;
  String::Utf8Value data(args[0]->ToString());
  int len;
  unsigned char* str=base64_encode((unsigned char*)*data,data.length(),&len);
  Local<String> ret = String::New((const char*)str,len);
  free(str);
  return ret;
}

problem with the package (npm)

node 0.1.103 (nvm) + npm

it seems npm generates an incorrect main.js file for node-base64 (this maybe because this module is compiled), the problem is in the line 5 (/lib/node/.npm/node-base64/0.0.1/main.js)

module.exports = require("./package/build/default/")

it should be:
module.exports = require("./package/build/default/base64")

I reported something similar to isaacs once and he thougth it's a problem in this file:

Bug in base64 package.json. It should read "main":"./build/default/base64"

thanks!
danielz

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.