You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2025/03/06 16:19:17 UTC
(tomcat) 01/02: Fix backport.
This is an automated email from the ASF dual-hosted git repository.
markt pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
commit fbba100186325251038b3f8cf2336aa04b0ce82c
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Thu Mar 6 16:17:37 2025 +0000
Fix backport.
---
.../org/apache/jasper/runtime/JspRuntimeLibrary.java | 20 ++++++++++++--------
1 file changed, 12 insertions(+), 8 deletions(-)
diff --git a/java/org/apache/jasper/runtime/JspRuntimeLibrary.java b/java/org/apache/jasper/runtime/JspRuntimeLibrary.java
index c2931821d4..559e5366ca 100644
--- a/java/org/apache/jasper/runtime/JspRuntimeLibrary.java
+++ b/java/org/apache/jasper/runtime/JspRuntimeLibrary.java
@@ -19,10 +19,9 @@ package org.apache.jasper.runtime;
import java.beans.PropertyEditor;
import java.beans.PropertyEditorManager;
import java.io.IOException;
+import java.io.UnsupportedEncodingException;
import java.lang.reflect.Method;
import java.net.URLEncoder;
-import java.nio.charset.Charset;
-import java.nio.charset.StandardCharsets;
import java.util.Enumeration;
import javax.servlet.RequestDispatcher;
@@ -1004,14 +1003,19 @@ public class JspRuntimeLibrary {
if (enc == null) {
enc = "ISO-8859-1"; // The default request encoding
}
- Charset cs = null;
+ String result = null;
+
try {
- cs = Charset.forName(enc);
- } catch (Throwable t) {
- ExceptionUtils.handleThrowable(t);
- cs = StandardCharsets.ISO_8859_1;
+ result = URLEncoder.encode(s, enc);
+ } catch (UnsupportedEncodingException uee) {
+ // Fallback to default.
+ try {
+ result = URLEncoder.encode(s, "ISO-8859-1");
+ } catch (UnsupportedEncodingException e) {
+ /// Should never happen.
+ }
}
- return URLEncoder.encode(s, cs);
+ return result;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org