Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.6.9

Bug #17628 Uncaught exception
Submitted: 2010-07-24 03:11 UTC
From: smscotten Assigned: gauthierm
Status: Closed Package: Crypt_GPG (version 1.1.1)
PHP Version: 5.2.12 OS: OS X 10.5.8
Roadmaps: (Not assigned)    
Subscription  


 [2010-07-24 03:11 UTC] smscotten (Steven Scotten)
Description: ------------ Result (below) is what I get in a stock MAMP environment (php.ini modified only to add the library path for PEAR packages) If I run 'usr/local/bin/gpg --help' the first line returned is: gpg (GnuPG) 1.4.10 So I'm pretty sure it's really GnuPG. Test script: --------------- <?php require_once('Crypt/GPG.php'); $gnupg = new Crypt_GPG(); $gnupg->addDecryptKey('KEY GOES HERE'); ?> Expected result: ---------------- nothing at all. Actual result: -------------- Fatal error: Uncaught Crypt_GPG_Exception: No GnuPG version information provided by the binary "/usr/local/bin/gpg". Are you sure it is GnuPG? in /usr/lib/php/Crypt/GPG/Engine.php on line 1391 Exception trace # Function Location 0 Crypt_GPG_Engine->getVersion() /usr/lib/php/Crypt/GPG/Engine.php:1391 1 Crypt_GPG_Engine->_openSubprocess() /usr/lib/php/Crypt/GPG/Engine.php:689 2 Crypt_GPG_Engine->run() /usr/lib/php/Crypt/GPG.php:722 3 Crypt_GPG->getKeys('[BEGINNING OF KEY]…') /usr/lib/php/Crypt in /usr/lib/php/Crypt/GPG/Engine.php on line 847

Comments

 [2010-07-26 19:04 UTC] gauthierm (Michael Gauthier)
Hi Steven, Are you using MAMP from www.mamp.info, or just with the tools provided by stock OS X? I'm not able to reproduce the issue using my 1.4.10 version of Crypt_GPG in Ubuntu 10.04. Can you do a dump of gpg --version and attach it to this bug so I can investigate further? I'm suspicious the line breaks are not equal to PHP_EOL. $gpg --version > gpg-version-dump
 [2010-08-20 12:55 UTC] alec (Aleksander Machniak)
I don't see a reason to use explode there. Proposed change: --- Engine.old 2010-08-20 09:27:04.818725258 +0200 +++ Engine.php 2010-08-20 10:54:01.035194377 +0200 @@ -837,11 +837,9 @@ $code); } - $info = explode(PHP_EOL, $info); - $matches = array(); - $expression = '/^gpg \(GnuPG\) (.*)$/'; + $expression = '/^gpg \(GnuPG\) (\S+)/'; - if (preg_match($expression, $info[0], $matches) === 1) { + if (preg_match($expression, $info, $matches) === 1) { $this->_version = $matches[1]; } else { throw new Crypt_GPG_Exception(
 [2010-08-20 12:55 UTC] alec (Aleksander Machniak)
Sorry, better formatting: --- Engine.old 2010-08-20 09:27:04.818725258 +0200 +++ Engine.php 2010-08-20 10:54:01.035194377 +0200 @@ -837,11 +837,9 @@ $code); } - $info = explode(PHP_EOL, $info); - $matches = array(); - $expression = '/^gpg \(GnuPG\) (.*)$/'; + $expression = '/^gpg \(GnuPG\) (\S+)/'; - if (preg_match($expression, $info[0], $matches) === 1) { + if (preg_match($expression, $info, $matches) === 1) { $this->_version = $matches[1]; } else { throw new Crypt_GPG_Exception(
 [2010-08-20 12:58 UTC] alec (Aleksander Machniak)
Now I think we could even use '/gpg \(GnuPG\) (\S+)/' instead.
 [2010-08-20 18:41 UTC] gauthierm (Michael Gauthier)
-Status: Open +Status: Feedback
I applied this change in revision 302559. http://svn.php.net/viewvc?view=revision&revision=302559 I'm not sure if it will fix the original bug as I was unable to reproduce the original bug. Steven, can you try applying this patch to your copy of Crypt_GPG and see if it works properly on your MAMP install?
 [2011-12-12 00:03 UTC] cvandeplas (Christophe Vandeplas)
The same problem is still present on Mac OS X. I'm also running pear within MAMP. Versions: Crypt_GPG 1.3.2 (stable) GNU Privacy Guard (GnuPG) The output of gpg is a little bit different than previous users. /usr/local/bin$ gpg --version gpg (GnuPG/MacGPG2) 2.0.17 I changed the regular expression to match a more broad format: gpg (GnuPG*) version_num I also changed the start/end of the regex from / to # to make it more readable as I needed to add a / in the regex. --- Engine.php.orig 2011-12-11 18:58:33.000000000 +0100 +++ Engine.php 2011-12-11 19:00:58.000000000 +0100 @@ -907,7 +907,7 @@ class Crypt_GPG_Engine } $matches = array(); - $expression = '/gpg \(GnuPG\) (\S+)/'; + $expression = '#gpg \(GnuPG[a-zA-Z0-9/]*\) (\S+)#'; if (preg_match($expression, $info, $matches) === 1) { $this->_version = $matches[1];
 [2012-01-06 22:05 UTC] gauthierm (Michael Gauthier)
-Status: Feedback +Status: Open
Christophe, your patch looks good. Crypt_GPG is now on github: https://github.com/pear/Crypt_GPG. Can you submit it as a pull request?
 [2013-02-28 09:22 UTC] gauthierm (Michael Gauthier)
https://github.com/pear/Crypt_GPG/pull/4 Fix will be in next release.
 [2013-02-28 09:44 UTC] gauthierm (Michael Gauthier)
-Status: Open +Status: Closed -Assigned To: +Assigned To: gauthierm
Thank you for your bug report. This issue has been fixed in the latest released version of the package, which you can download at http://pear.php.net/get/