This is an automated email from the ASF dual-hosted git repository.

cstamas pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-gpg-plugin.git


The following commit(s) were added to refs/heads/master by this push:
     new 23b64f2  [MGPG-99] Make sure newline is added to input stream (#76)
23b64f2 is described below

commit 23b64f29dde787f35bafbe56da1e56567c45e798
Author: Tamas Cservenak <ta...@cservenak.net>
AuthorDate: Tue Mar 5 10:05:42 2024 +0100

    [MGPG-99] Make sure newline is added to input stream (#76)
    
    When passphrase is being supplied with `--passphrase-fd 0`.
    
    ---
    
    https://issues.apache.org/jira/browse/MGPG-99
---
 src/main/java/org/apache/maven/plugins/gpg/GpgSigner.java | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/main/java/org/apache/maven/plugins/gpg/GpgSigner.java 
b/src/main/java/org/apache/maven/plugins/gpg/GpgSigner.java
index deaff7b..673e50d 100644
--- a/src/main/java/org/apache/maven/plugins/gpg/GpgSigner.java
+++ b/src/main/java/org/apache/maven/plugins/gpg/GpgSigner.java
@@ -108,7 +108,11 @@ public class GpgSigner extends AbstractGpgSigner {
             cmd.createArg().setValue("0");
 
             // Prepare the input stream which will be used to pass the 
passphrase to the executable
-            in = new ByteArrayInputStream(passphrase.getBytes());
+            if (!passphrase.endsWith(System.lineSeparator())) {
+                in = new ByteArrayInputStream((passphrase + 
System.lineSeparator()).getBytes());
+            } else {
+                in = new ByteArrayInputStream(passphrase.getBytes());
+            }
         }
 
         if (null != keyname) {

Reply via email to