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

astefanutti pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-k.git

commit aa89ed2d423f855aad2aaabf5bde583801063b34
Author: Antonin Stefanutti <[email protected]>
AuthorDate: Mon Jan 10 14:57:11 2022 +0100

    fix(jvm): Quote HTTP proxy system property values
---
 pkg/trait/jvm.go | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/pkg/trait/jvm.go b/pkg/trait/jvm.go
index 3c5fa6c..e1bc3e4 100644
--- a/pkg/trait/jvm.go
+++ b/pkg/trait/jvm.go
@@ -179,15 +179,15 @@ func (t *jvmTrait) Apply(e *Environment) error {
                        return err
                }
                if !util.StringSliceContainsAnyOf(t.Options, "http.proxyHost") {
-                       args = append(args, "-Dhttp.proxyHost="+u.Hostname())
+                       args = append(args, fmt.Sprintf("-Dhttp.proxyHost=%q", 
u.Hostname()))
                }
                if port := u.Port(); !util.StringSliceContainsAnyOf(t.Options, 
"http.proxyPort") && port != "" {
-                       args = append(args, "-Dhttp.proxyPort="+u.Port())
+                       args = append(args, fmt.Sprintf("-Dhttp.proxyPort=%q", 
u.Port()))
                }
                if user := u.User; !util.StringSliceContainsAnyOf(t.Options, 
"http.proxyUser") && user != nil {
-                       args = append(args, "-Dhttp.proxyUser="+user.Username())
+                       args = append(args, fmt.Sprintf("-Dhttp.proxyUser=%q", 
user.Username()))
                        if password, ok := user.Password(); 
!util.StringSliceContainsAnyOf(t.Options, "http.proxyUser") && ok {
-                               args = append(args, 
"-Dhttp.proxyPassword="+password)
+                               args = append(args, 
fmt.Sprintf("-Dhttp.proxyPassword=%q", password))
                        }
                }
        }
@@ -198,15 +198,15 @@ func (t *jvmTrait) Apply(e *Environment) error {
                        return err
                }
                if !util.StringSliceContainsAnyOf(t.Options, "https.proxyHost") 
{
-                       args = append(args, "-Dhttps.proxyHost="+u.Hostname())
+                       args = append(args, fmt.Sprintf("-Dhttps.proxyHost=%q", 
u.Hostname()))
                }
                if port := u.Port(); !util.StringSliceContainsAnyOf(t.Options, 
"https.proxyPort") && port != "" {
-                       args = append(args, "-Dhttps.proxyPort="+u.Port())
+                       args = append(args, fmt.Sprintf("-Dhttps.proxyPort=%q", 
u.Port()))
                }
                if user := u.User; !util.StringSliceContainsAnyOf(t.Options, 
"https.proxyUser") && user != nil {
-                       args = append(args, 
"-Dhttps.proxyUser="+user.Username())
+                       args = append(args, fmt.Sprintf("-Dhttps.proxyUser=%q", 
user.Username()))
                        if password, ok := user.Password(); 
!util.StringSliceContainsAnyOf(t.Options, "https.proxyUser") && ok {
-                               args = append(args, 
"-Dhttps.proxyPassword="+password)
+                               args = append(args, 
fmt.Sprintf("-Dhttps.proxyPassword=%q", password))
                        }
                }
        }
@@ -220,7 +220,7 @@ func (t *jvmTrait) Apply(e *Environment) error {
                                        hosts[i] = strings.Replace(host, ".", 
"*.", 1)
                                }
                        }
-                       args = append(args, 
"-Dhttp.nonProxyHosts="+strings.Join(hosts, "|"))
+                       args = append(args, 
fmt.Sprintf("-Dhttp.nonProxyHosts=%q", strings.Join(hosts, "|")))
                }
        }
 

Reply via email to