lukaszlenart commented on code in PR #861:
URL: https://github.com/apache/struts/pull/861#discussion_r1608537187
##########
core/src/main/java/org/apache/struts2/dispatcher/multipart/AbstractMultiPartRequest.java:
##########
@@ -171,4 +298,109 @@ protected String getCanonicalName(final String
originalFileName) {
return fileName;
}
+ protected String sanitizeNewlines(String before) {
+ return before.replaceAll("\\R", "_");
+ }
+
+ /* (non-Javadoc)
+ * @see
org.apache.struts2.dispatcher.multipart.MultiPartRequest#getErrors()
+ */
+ public List<LocalizedMessage> getErrors() {
+ return errors;
+ }
+
+ /* (non-Javadoc)
+ * @see
org.apache.struts2.dispatcher.multipart.MultiPartRequest#getFileParameterNames()
+ */
+ public Enumeration<String> getFileParameterNames() {
+ return Collections.enumeration(uploadedFiles.keySet());
+ }
+
+ /* (non-Javadoc)
+ * @see
org.apache.struts2.dispatcher.multipart.MultiPartRequest#getContentType(java.lang.String)
+ */
+ public String[] getContentType(String fieldName) {
+ return uploadedFiles.getOrDefault(fieldName,
Collections.emptyList()).stream()
+ .map(UploadedFile::getContentType)
+ .toArray(String[]::new);
+ }
+
+ /* (non-Javadoc)
+ * @see
org.apache.struts2.dispatcher.multipart.MultiPartRequest#getFile(java.lang.String)
+ */
+ @SuppressWarnings("unchecked")
+ public UploadedFile<T>[] getFile(String fieldName) {
+ return uploadedFiles.getOrDefault(fieldName, Collections.emptyList())
+ .toArray(UploadedFile[]::new);
+ }
+
+ /* (non-Javadoc)
+ * @see
org.apache.struts2.dispatcher.multipart.MultiPartRequest#getFileNames(java.lang.String)
+ */
+ public String[] getFileNames(String fieldName) {
+ return uploadedFiles.getOrDefault(fieldName,
Collections.emptyList()).stream()
+ .map(file -> getCanonicalName(file.getName()))
+ .toArray(String[]::new);
+ }
+
+ /* (non-Javadoc)
+ * @see
org.apache.struts2.dispatcher.multipart.MultiPartRequest#getFilesystemName(java.lang.String)
+ */
+ public String[] getFilesystemName(String fieldName) {
+ return uploadedFiles.getOrDefault(fieldName,
Collections.emptyList()).stream()
+ .map(UploadedFile::getAbsolutePath)
+ .toArray(String[]::new);
+ }
+
+ /* (non-Javadoc)
+ * @see
org.apache.struts2.dispatcher.multipart.MultiPartRequest#getParameter(java.lang.String)
+ */
+ public String getParameter(String name) {
+ List<String> paramValue = parameters.getOrDefault(name,
Collections.emptyList());
+ if (!paramValue.isEmpty()) {
+ return paramValue.get(0);
+ }
+
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see
org.apache.struts2.dispatcher.multipart.MultiPartRequest#getParameterNames()
+ */
+ public Enumeration<String> getParameterNames() {
+ return Collections.enumeration(parameters.keySet());
+ }
+
+ /* (non-Javadoc)
+ * @see
org.apache.struts2.dispatcher.multipart.MultiPartRequest#getParameterValues(java.lang.String)
+ */
+ public String[] getParameterValues(String name) {
+ return parameters.getOrDefault(name, Collections.emptyList())
+ .toArray(String[]::new);
Review Comment:
@criderp please register this bug in
[JIRA](https://issues.apache.org/jira/browse/WW), thanks!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]