upwork/php-upwork

Bad formatting of message

Closed this issue · 3 comments

reedy commented

https://github.com/upwork/php-upwork/blob/master/src/Upwork/API/AuthTypes/AbstractOAuth.php#L150-L152

Ends up with the code outputting something along the lines of:

Visit https://www.upwork.com/services/api/auth?oauth_token=a1b2c3d4and provide oauth_verifier for further authorization$ 

None of the new lines are respected, and the and is put at the end of the token. This makes copying the url a harder process, and the whole thing harder to read

reedy commented

Seems to be related to readline

php > $authUrl = 'http://foo.bar/';
php > $prompt = 'Visit ' . $authUrl . "\n" . 'and provide oauth_verifier for further authorization' . "\n" .'$ ';
php > echo $prompt;
Visit http://foo.bar/
and provide oauth_verifier for further authorization
$ 
php > readline($prompt);
Visit http://foo.bar/and provide oauth_verifier for further authorization$ 
reedy commented
$ dpkg -l | grep readline
ii  libreadline-dev:amd64               7.0-0ubuntu2                             amd64        GNU readline and history libraries, development files
ii  libreadline6:amd64                  6.3-8ubuntu8                             amd64        GNU readline and history libraries, run-time libraries
ii  libreadline7:amd64                  7.0-0ubuntu2                             amd64        GNU readline and history libraries, run-time libraries
ii  php7.0-readline                     7.0.18-0ubuntu0.17.04.1                  amd64        readline module for PHP
ii  readline-common                     7.0-0ubuntu2                             all          GNU readline and history libraries, common files
$ uname -a
Linux ubuntu64-web-esxi 4.10.0-28-generic #32-Ubuntu SMP Fri Jun 30 05:32:18 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
$ php --version
PHP 7.0.18-0ubuntu0.17.04.1 (cli) (built: Apr 26 2017 23:59:48) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
    with Zend OPcache v7.0.18-0ubuntu0.17.04.1, Copyright (c) 1999-2017, by Zend Technologies
    with Xdebug v2.5.0, Copyright (c) 2002-2016, by Derick Rethans
$ php -a
Interactive mode enabled

php > $authUrl = 'http://foo.bar/';
php > $prompt = 'Visit ' . $authUrl . "\n" . 'and provide oauth_verifier for further authorization' . "\n" .'$ ';
php > echo $prompt;
Visit http://foo.bar/
and provide oauth_verifier for further authorization
$
php > readline($prompt);
Visit http://foo.bar/and provide oauth_verifier for further authorization$
php >
php >

Fixed in fe34f2d , v1.2.4

Thank you for the contribution!