Git Product home page Git Product logo

Comments (4)

xabbuh avatar xabbuh commented on July 17, 2024

Can you give a simple example that does not lead to the same result as when using the built-in function?

from polyfill.

fuhry avatar fuhry commented on July 17, 2024
fuhrymbp :: ~ » php --version
PHP 5.5.30 (cli) (built: Oct 23 2015 17:21:45) 
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2015 Zend Technologies
fuhrymbp :: ~ » php -r 'echo hex2bin("6162006364");' | xxd
0000000: 6162 0063 64                             ab.cd

from polyfill.

binwiederhier avatar binwiederhier commented on July 17, 2024

No indication of a special case for \0 anywhere in PHP 5.4/5.5/7.0:
https://github.com/php/php-src/blob/PHP-5.4.45/ext/standard/string.c#L157
https://github.com/php/php-src/blob/PHP-5.5.33/ext/standard/string.c#L157
https://github.com/php/php-src/blob/PHP-7.0.5/ext/standard/string.c#L157

And @fuhry's example above shows that the PHP 5.5 version does not reject hex strings with 00 in it. As an ugly workaround, we're doing some really nasty as a post-install composer thing:

    "scripts": {
        "post-autoload-dump": [
            "echo 'Replacing broken hex2bin in Symfony ...'",
            "sed -i 's/p\\\\Php54::hex2bin/\\\\Util\\\\StringUtil::hex2bin/g' vendor/symfony/polyfill-php54/bootstrap.php",
            "grep StringUtil vendor/symfony/polyfill-php54/bootstrap.php"
        ]
    }

Merging the pull would make our lives a lot easier :-D

from polyfill.

binwiederhier avatar binwiederhier commented on July 17, 2024

Just noticed that someone else is having the same issue: #46

from polyfill.

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.