Giter Site home page Giter Site logo

Comments (12)

aklt avatar aklt commented on August 16, 2024

This seems to be fixed by this patch: https://gist.github.com/896558

from node-iconv.

aklt avatar aklt commented on August 16, 2024

Hmm, I was a bit quick there, only some of the problem went away. The output is now:

+AO +AO +AO

but a final 'c' is missing.

from node-iconv.

papandreou avatar papandreou commented on August 16, 2024

There's similar, yet subtly different breakage the other way around:

var converter = new (require('iconv')).Iconv('utf-7', 'utf-8'),
    utf7cedilla = new Buffer([0x2b, 0x41, 0x4f, 0x63]); // "+AOc" in ASCII
converter.convert(utf7cedilla).toString(); // 'ç'
converter.convert(utf7cedilla).toString(); // EINVAL, Incomplete character sequence.
converter.convert(utf7cedilla).toString(); // 'ç'
converter.convert(utf7cedilla).toString(); // EINVAL, Incomplete character sequence.
// etc.

from node-iconv.

bnoordhuis avatar bnoordhuis commented on August 16, 2024

I wrote a test case in plain C that exhibits the same behaviour so it seems you've uncovered a bug in libiconv.

I'm trying to check it against the bleeding edge but it's proving exceedingly difficult to build, one of the in-tree build tools dies with a buffer overrun if FORTIFY_SOURCE is enabled.

To be continued.

from node-iconv.

aklt avatar aklt commented on August 16, 2024

I guess one could argue that this is a bug with libiconv since the
last parameter (outbufsize) to iconv() is not updated correctly.

Still

echo -n 'ç'  | ./iconv_no_i18n -f 'UTF-8' -t 'UTF-7'

Does the right thing because outbufsize is not used to determine
the size of output in iconv.c. Instead the difference between the two
pointers is used to fwrite() the correct amount of bytes (iconv.c line 707).

In node-iconv the difference between these is not correct for this example. I think the reason may be that iconvctl is used to set some hooks in iconv.c,
specifically the update_line_column seems to be called....

Now I need to get some sleep :-)

from node-iconv.

aklt avatar aklt commented on August 16, 2024

Ups, accidentally closed the issue but it seems it cannot be reopened, hmm,...

from node-iconv.

bnoordhuis avatar bnoordhuis commented on August 16, 2024

No problem, I've reopened it.

from node-iconv.

bnoordhuis avatar bnoordhuis commented on August 16, 2024

My bad, it turns out that this is indeed a bug in node-iconv: the trailer isn't written correctly. I'll try to push out a fix tomorrow.

from node-iconv.

bnoordhuis avatar bnoordhuis commented on August 16, 2024

Fixed in commit 58764b2.

Can I have one or more 'works for me too', please? :-)

from node-iconv.

papandreou avatar papandreou commented on August 16, 2024

WFM, too :)

from node-iconv.

bnoordhuis avatar bnoordhuis commented on August 16, 2024

Cool, thanks. I've uploaded 1.0.1 to npm just now.

from node-iconv.

aklt avatar aklt commented on August 16, 2024

Cool, thanks for the quick update :-)

from node-iconv.

Related Issues (20)

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.