[
https://issues.apache.org/jira/browse/WW-4514?focusedWorklogId=823290&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-823290
]
ASF GitHub Bot logged work on WW-4514:
--------------------------------------
Author: ASF GitHub Bot
Created on: 04/Nov/22 08:00
Start Date: 04/Nov/22 08:00
Worklog Time Spent: 10m
Work Description: github-code-scanning[bot] commented on code in PR #630:
URL: https://github.com/apache/struts/pull/630#discussion_r1013716930
##########
core/src/main/java/org/apache/struts2/url/StrutsParametersStringBuilder.java:
##########
@@ -0,0 +1,91 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.struts2.url;
+
+import com.opensymphony.xwork2.inject.Inject;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+import java.util.Map;
+
+public class StrutsParametersStringBuilder implements ParametersStringBuilder {
+
+ private static final Logger LOG =
LogManager.getLogger(StrutsParametersStringBuilder.class);
+
+ private final UrlEncoder encoder;
+
+ @Inject
+ public StrutsParametersStringBuilder(UrlEncoder encoder) {
+ this.encoder = encoder;
+ }
+
+ @Override
+ public void buildParametersString(Map<String, Object> params,
StringBuilder link, String paramSeparator) {
+ if ((params != null) && (params.size() > 0)) {
+ LOG.debug("Building query string out of: {}", params);
Review Comment:
## Logging should not be vulnerable to injection attacks
<!--SONAR_ISSUE_KEY:AYRBpyEih8GBiPIxzeuL-->Change this code to not log
user-controlled data. <p>See more on <a
href="https://sonarcloud.io/project/issues?id=apache_struts&issues=AYRBpyEih8GBiPIxzeuL&open=AYRBpyEih8GBiPIxzeuL&pullRequest=630">SonarCloud</a></p>
[Show more
details](https://github.com/apache/struts/security/code-scanning/203)
Issue Time Tracking
-------------------
Worklog Id: (was: 823290)
Time Spent: 0.5h (was: 20m)
> DefaultUrlHelper.buildParametersString appends just ? if collection is empty
> ----------------------------------------------------------------------------
>
> Key: WW-4514
> URL: https://issues.apache.org/jira/browse/WW-4514
> Project: Struts 2
> Issue Type: Bug
> Components: Core Actions
> Affects Versions: 2.3.24
> Reporter: Jasper Rosenberg
> Assignee: Lukasz Lenart
> Priority: Trivial
> Fix For: 6.1.0
>
> Attachments: DefaultUrlHelper.patch
>
> Time Spent: 0.5h
> Remaining Estimate: 0h
>
> DefaultUrlHelper.buildParametersString() checks that it has parameters to
> append before adding the first "?"/"&", but if the only parameters are empty
> Iterables/Arrays, then it shouldn't do that.
> I'd suggest adding the new query string to a StringBuilder, and then if it is
> non-empty, append that with the separator to the link at the end. (See patch)
--
This message was sent by Atlassian Jira
(v8.20.10#820010)