magento / composer

Open Software License 3.0
31 stars 23 forks source link

Backspace character (\x08) from overwriteError causes parsing issues in Magento2 #8

Open bplatak opened 7 years ago

bplatak commented 7 years ago

Magento2 has an issue (https://github.com/magento/magento2/issues/6372) which originates from InfoCommand.php.

Using composer.json with a VCS (git) repository:

"repositories": {
    ...
    "craftyclicks": {
        "type": "git",
        "url": "https://github.com/craftyclicks/m2-ukpostcodelookup.git"
    }
}

In InfoCommand::run(...) the output string ($output) is split into lines (using explode) and further split on : to create an associative array of values. The $output variable at that point contains:

<warning>You are running composer with xdebug enabled. This has a major impact on runtime performance. See https://getcomposer.org/xdebug</warning>
<warning>Warning from https://repo.packagist.com/ebizmartscorp: 
======================

COMPOSER VERSION WARNING

Your Composer is outdated, it is highly recommended to use v1.3.0 or above to avoid slowing down Packagist.com updates

======================
</warning>
Reading composer.json of craftyclicks/module-ukpostcodelookup (master)                                                                      name     : magento/product-community-edition
descrip. : eCommerce Platform for Growth (Community Edition)
keywords : 
versions : * 2.1.7, 2.1.6, 2.1.5, 2.1.4, 2.1.3, 2.1.2, 2.1.1, 2.1.0, 2.1.0-rc3, 2.1.0-rc2, 2.1.0-rc1, 2.0.15, 2.0.14, 2.0.13, 2.0.12, 2.0.11, 2.0.10, 2.0.9, 2.0.8, 2.0.7, 2.0.6, 2.0.5, 2.0.4, 2.0.3, 2.0.2, 2.0.1, 2.0.0, 0.42.0-beta7
type     : metapackage
license  : Open Software License 3.0 (OSL-3.0) (OSI approved) https://spdx.org/licenses/OSL-3.0.html#licenseText
license  : Academic Free License v3.0 (AFL-3.0) (OSI approved) https://spdx.org/licenses/AFL-3.0.html#licenseText
source   : []  
dist     : [zip] https://repo.magento.com/archives/magento/product-community-edition/magento-product-community-edition-2.1.7.0.zip 
names    : magento/product-community-edition

requires
magento/magento2-base 2.1.7
php ~5.6.5|7.0.2|7.0.4|~7.0.6
zendframework/zend-stdlib ~2.4.6
...

Where is actually \x08 coming from ConsoleIO::doOverwrite. The stacktrace is: 2017-07-21-170652_1028x618_scrot

This results in the name attribute not being added to the result and causing issues further down the line. As a temporary fix, I have added a preg_replace('/\x08+/', "\n", $output) which seems to work. It may also be possible to change the newline parameter of ConsoleIO::doOverwrite.

This leads me to two questions: