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

remm pushed a commit to branch 10.1.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/10.1.x by this push:
     new 5e4901891f Throw on bad scope error
5e4901891f is described below

commit 5e4901891f0853b527dbfc320d456e87af0723b8
Author: remm <r...@apache.org>
AuthorDate: Wed Sep 20 17:39:32 2023 +0200

    Throw on bad scope error
    
    Just in case (it doesn't happen in the current code obviously). Also add
    missing localization.
    Found by coverity.
---
 java/org/apache/jasper/compiler/Generator.java           | 12 ++----------
 java/org/apache/jasper/compiler/Node.java                |  4 ++++
 java/org/apache/jasper/resources/LocalStrings.properties |  2 ++
 3 files changed, 8 insertions(+), 10 deletions(-)

diff --git a/java/org/apache/jasper/compiler/Generator.java 
b/java/org/apache/jasper/compiler/Generator.java
index e8c1febd85..7fa420cf9c 100644
--- a/java/org/apache/jasper/compiler/Generator.java
+++ b/java/org/apache/jasper/compiler/Generator.java
@@ -1237,15 +1237,7 @@ class Generator {
                         + property
                         + "\")));");
             } else {
-                StringBuilder msg = new StringBuilder();
-                msg.append("file:");
-                msg.append(n.getStart());
-                msg.append(" jsp:getProperty for bean with name '");
-                msg.append(name);
-                msg.append(
-                        "'. Name was not previously introduced as per 
JSP.5.3");
-
-                throw new JasperException(msg.toString());
+                throw new 
JasperException(Localizer.getMessage("jsp.error.invalid.name", n.getStart(), 
name));
             }
 
             n.setEndJavaLine(out.getJavaLine());
@@ -1370,7 +1362,7 @@ class Generator {
                     if (!Modifier.isPublic(modifiers) ||
                             Modifier.isAbstract(modifiers) ||
                             !constructor.canAccess(null) ) {
-                        throw new 
Exception(Localizer.getMessage("jsp.error.invalid.bean",
+                        throw new 
JasperException(Localizer.getMessage("jsp.error.invalid.bean",
                                 Integer.valueOf(modifiers)));
                     }
                     // At compile time, we have determined that the bean class
diff --git a/java/org/apache/jasper/compiler/Node.java 
b/java/org/apache/jasper/compiler/Node.java
index 3af6337a82..b10d5cc90d 100644
--- a/java/org/apache/jasper/compiler/Node.java
+++ b/java/org/apache/jasper/compiler/Node.java
@@ -1681,6 +1681,8 @@ abstract class Node implements TagConstants {
             case VariableInfo.NESTED:
                 this.nestedScriptingVars = vec;
                 break;
+            default:
+                throw new 
IllegalArgumentException(Localizer.getMessage("jsp.error.page.invalid.varscope",
 scope));
             }
         }
 
@@ -1701,6 +1703,8 @@ abstract class Node implements TagConstants {
             case VariableInfo.NESTED:
                 vec = this.nestedScriptingVars;
                 break;
+            default:
+                throw new 
IllegalArgumentException(Localizer.getMessage("jsp.error.page.invalid.varscope",
 scope));
             }
 
             return vec;
diff --git a/java/org/apache/jasper/resources/LocalStrings.properties 
b/java/org/apache/jasper/resources/LocalStrings.properties
index 35c192f240..8552b1eda6 100644
--- a/java/org/apache/jasper/resources/LocalStrings.properties
+++ b/java/org/apache/jasper/resources/LocalStrings.properties
@@ -88,8 +88,10 @@ jsp.error.invalid.directive=Invalid directive
 jsp.error.invalid.expression=[{0}] contains invalid expression(s): [{1}]
 jsp.error.invalid.implicit=Invalid implicit TLD for tag file at [{0}]
 jsp.error.invalid.implicit.version=Invalid JSP version defined in implicit TLD 
for tag file at [{0}]
+jsp.error.invalid.name=File [{0}] uses name [{1}] in jsp:getProperty for a 
bean that was not previously introduced as per JSP.5.3
 jsp.error.invalid.scope=Illegal value of ''scope'' attribute: [{0}] (must be 
one of "page", "request", "session", or "application")
 jsp.error.invalid.tagdir=Tag file directory [{0}] does not start with 
"/WEB-INF/tags"
+jsp.error.invalid.varscope=Invalid variable scope [{0}]
 jsp.error.invalid.version=Invalid JSP version defined for tag file at [{0}]
 jsp.error.ise_on_clear=Illegal to clear() when buffer size == 0
 jsp.error.java.line.number=An error occurred at line: [{0}] in the generated 
java file: [{1}]


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to