From aec53f44259b442e1d2ef49fdb30f1aa4a2df4b5 Mon Sep 17 00:00:00 2001 From: hns Date: Tue, 27 Nov 2001 14:15:18 +0000 Subject: [PATCH] Added code to find out if a property is defined in the type.properties file before returning its value as a macro. Return an error message if the property is not defined, or if the macro tried to access a private property (which currently applies only to user passwords). --- src/helma/framework/core/RequestEvaluator.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/helma/framework/core/RequestEvaluator.java b/src/helma/framework/core/RequestEvaluator.java index d407bf01..8b723b44 100644 --- a/src/helma/framework/core/RequestEvaluator.java +++ b/src/helma/framework/core/RequestEvaluator.java @@ -1032,14 +1032,20 @@ public class RequestEvaluator implements Runnable { * is a java object) with that name. */ public Object getProperty (Object obj, String propname) { - if (obj == null) + if (obj == null || propname == null) return null; String prototypeName = app.getPrototypeName (obj); if ("user".equalsIgnoreCase (prototypeName) && "password".equalsIgnoreCase (propname)) - return null; + return "[macro access to password property not allowed]"; + DbMapping dbm = app.getDbMapping (prototypeName); + if (dbm != null) { + Relation rel = dbm.propertyToRelation (propname); + if (rel == null || !rel.isPrimitive ()) + return "[property \""+propname+"\" is not defined for "+prototypeName+"]"; + } ESObject eso = getElementWrapper (obj); try { ESValue prop = eso.getProperty (propname, propname.hashCode());