bitpay / php-bitpay-client

PHP implementation for the BitPay cryptographically secure RESTful API
MIT License
165 stars 149 forks source link

"Undefined Offset 2" PHP 7.3.4-2/Debian 10 #304

Open boooyu44 opened 4 years ago

boooyu44 commented 4 years ago

While trying to create invoice the library has problem parsing response. Looks critical as it triggers exception with "undefined offset 2"

More details and stack trace on the image

https://i.imgur.com/zScVIWg.png https://i.imgur.com/4Cnmaab.png

PHP 7.3.4-2/Debian 10

thes01 commented 4 years ago

The issue is in the regex pattern which does not accept the string starting with "HTTP 2 " (it expects HTTP number.number ...). Solved by (making a fork and) replacing the regex pattern like this in Bitpay/Client/Response.php

preg_match('/^HTTP\/(\d)\s(\d+)\s(.*)/', $lines[$i], $statusLine);