[java-shib-attribute] 01/02: Simplify sandbox

Rod Widdowson rdw at steadingsoftware.com
Thu Jan 25 15:00:06 UTC 2024


This is an automated email from the git hooks/post-receive script.

rdw pushed a commit to branch dev/IDP-226
in repository java-shib-attribute.

View the commit online:
http://git.shibboleth.net/view/?p=java-shib-attribute.git;a=commit;h=aeaf7c9b6a207b51b1331810776c6a44436762bf

commit aeaf7c9b6a207b51b1331810776c6a44436762bf
Author: Rod Widdowson <rdw at steadingsoftware.com>
AuthorDate: Tue Jan 23 19:44:12 2024 +0000

    Simplify sandbox
---
 .../resolver/dc/impl/ThymeLeafSandbox.java         | 40 ++++++----------------
 1 file changed, 10 insertions(+), 30 deletions(-)

diff --git a/shib-attribute-resolver-impl/src/test/java/net/shibboleth/idp/attribute/resolver/dc/impl/ThymeLeafSandbox.java b/shib-attribute-resolver-impl/src/test/java/net/shibboleth/idp/attribute/resolver/dc/impl/ThymeLeafSandbox.java
index 17f5ea008..c62a8fda5 100644
--- a/shib-attribute-resolver-impl/src/test/java/net/shibboleth/idp/attribute/resolver/dc/impl/ThymeLeafSandbox.java
+++ b/shib-attribute-resolver-impl/src/test/java/net/shibboleth/idp/attribute/resolver/dc/impl/ThymeLeafSandbox.java
@@ -39,6 +39,7 @@ import org.thymeleaf.processor.text.AbstractTextProcessor;
 import org.thymeleaf.processor.text.ITextStructureHandler;
 import org.thymeleaf.standard.StandardDialect;
 import org.thymeleaf.standard.inline.AbstractStandardInliner;
+import org.thymeleaf.standard.processor.StandardInliningTextProcessor;
 import org.thymeleaf.templatemode.TemplateMode;
 import org.thymeleaf.templateresolver.StringTemplateResolver;
 
@@ -76,7 +77,7 @@ public class ThymeLeafSandbox {
         final TemplateSpec spec = new TemplateSpec(templateStr, TemplateMode.TEXT);
 
         final String output = engine.process(spec, ctx);
-        assertEquals(output, "Nibble a happy " + map.get("warthog") + " says " + obj.getThing1() + " or " +  obj.getThing2());
+        assertEquals(output, "Nibble a happy " + map.get("warthog") + " says " + obj.getThing1().substring(3) + " or " +  obj.getThing2().substring(3));
     }
 
 	private class MyObject {
@@ -84,32 +85,6 @@ public class ThymeLeafSandbox {
 		public String getThing2() { return "Thing2"; }
 	}
 
-	class SandBoxProcessor extends AbstractTextProcessor  {
-
-        public SandBoxProcessor(TemplateMode templateMode, int precedence) {
-            super(templateMode, precedence);
-        }
-
-        @Override
-        protected void doProcess(ITemplateContext context, IText text, ITextStructureHandler structureHandler) {
-
-            if (EngineEventUtils.isWhitespace(text)) {
-                return;
-            }
-
-            final IInliner inliner = context.getInliner();  // OVERRIDE POINT
-
-            if (inliner == null || inliner == NoOpInliner.INSTANCE) {
-                return;
-            }
-
-            final CharSequence inlined = inliner.inline(context, text);
-            if (inlined != null && inlined != text) {
-                structureHandler.setText(inlined);
-            }
-        }
-	}
-	
 	public final class SandboxTemplateBoundariesProcessor extends AbstractTemplateBoundariesProcessor {
 
 	    public static final int PRECEDENCE = 11;
@@ -158,8 +133,13 @@ public class ThymeLeafSandbox {
 
         @Override
         protected String produceEscapedOutput(Object input) {
-            // TODO Auto-generated method stub
-            return null;
+            if (input instanceof String str) {
+                if (str.startsWith("Thi")) {
+                    return str.substring(3);
+                }
+                return str;
+             }
+            return input.toString();
         }
 	    
 	}
@@ -175,7 +155,7 @@ public class ThymeLeafSandbox {
 
 	    public Set<IProcessor> getProcessors(final String dialectPrefix) {
 	        return CollectionSupport.setOf(
-	                new SandBoxProcessor(TemplateMode.TEXT, getDialectProcessorPrecedence()),
+	                new StandardInliningTextProcessor(TemplateMode.TEXT), // Need this
 	                new SandboxTemplateBoundariesProcessor(TemplateMode.TEXT));
 	    }
 	}

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the commits mailing list