From 212c3e14c85265a30b66b79002c93946687b7468 Mon Sep 17 00:00:00 2001 From: Zac Spitzer Date: Tue, 18 Jul 2023 16:10:06 +0200 Subject: [PATCH] LDEV-3451 add a test to use cfapplication to override defaults --- .../functions/system/GetApplicationSettings.java | 6 +++--- test/tickets/LDEV1676.cfc | 14 ++++++++++++++ test/tickets/LDEV1676/Application.cfc | 1 + test/tickets/LDEV1676/LDEV1676.cfm | 11 +++++++++-- 4 files changed, 27 insertions(+), 5 deletions(-) diff --git a/core/src/main/java/lucee/runtime/functions/system/GetApplicationSettings.java b/core/src/main/java/lucee/runtime/functions/system/GetApplicationSettings.java index 71ec7e59af..b5acd6d95c 100644 --- a/core/src/main/java/lucee/runtime/functions/system/GetApplicationSettings.java +++ b/core/src/main/java/lucee/runtime/functions/system/GetApplicationSettings.java @@ -93,9 +93,9 @@ public static Struct call(PageContext pc, boolean suppressFunctions) throws Page Struct xmlFeatures = acs.getXmlFeatures(); if (xmlFeatures == null) xmlFeatures = new StructImpl(); Struct sxml = new StructImpl(Struct.TYPE_LINKED); - sxml.setEL("secure", Caster.toBoolean(xmlFeatures.get("secure", true))); - sxml.setEL("disallowDoctypeDecl", Caster.toBoolean(xmlFeatures.get("disallowDoctypeDecl", true))); - sxml.setEL("externalGeneralEntities", Caster.toBoolean(xmlFeatures.get("externalGeneralEntities", false))); + sxml.setEL("secure", xmlFeatures.get("secure", true)); + sxml.setEL("disallowDoctypeDecl", xmlFeatures.get("disallowDoctypeDecl", true)); + sxml.setEL("externalGeneralEntities", xmlFeatures.get("externalGeneralEntities", false)); sct.setEL("xmlFeatures", sxml); sct.setEL("customTagPaths", toArray(ac.getCustomTagMappings())); diff --git a/test/tickets/LDEV1676.cfc b/test/tickets/LDEV1676.cfc index 7e38e31591..6c095a8c51 100644 --- a/test/tickets/LDEV1676.cfc +++ b/test/tickets/LDEV1676.cfc @@ -94,6 +94,20 @@ component extends = "org.lucee.cfml.test.LuceeTestCase" labels="xml" { expect( trim( result ) ).toBe("lucee"); }); + // check if we can inline disable the settings back to the old behavior + it( title="Check xmlFeatures default, bad xml, cfapplication override",body = function ( currentSpec ) { + local.result = _InternalRequest( + template : "#uri#/LDEV1676.cfm", + forms : { + scene: "default", + doctype: true, + entity: true, + cfapplicationOverride: true + } + ).filecontent; + expect( trim( result ) ).toInclude("http://update.lucee.org/rest/update/provider/echoGet/cgi"); + }); + }); describe( "check bad config handling", function () { diff --git a/test/tickets/LDEV1676/Application.cfc b/test/tickets/LDEV1676/Application.cfc index 7d7a2199e4..e8322eb3b2 100644 --- a/test/tickets/LDEV1676/Application.cfc +++ b/test/tickets/LDEV1676/Application.cfc @@ -3,6 +3,7 @@ component { param name="FORM.Scene"; param name="FORM.docType" default="true"; param name="FORM.entity" default="true"; + param name="FORM.cfapplicationOverride" default="false"; switch (FORM.Scene){ case "externalGeneralEntities-True": diff --git a/test/tickets/LDEV1676/LDEV1676.cfm b/test/tickets/LDEV1676/LDEV1676.cfm index 98cc52dc69..b75777710c 100644 --- a/test/tickets/LDEV1676/LDEV1676.cfm +++ b/test/tickets/LDEV1676/LDEV1676.cfm @@ -14,6 +14,15 @@ + + if (form.cfapplicationOverride){ + //systemOutput("cfapplicationOverride", true) + application action="update" xmlFeatures={ + "externalGeneralEntities": true, + "secure": false, + "disallowDoctypeDecl": false + }; + } /* settings = getApplicationSettings(); @@ -31,9 +40,7 @@ //systemOutput( result, true ); echo( result ); } catch (e) { - //systemOutput(cfcatch.type & " " & cfcatch.message, true); - echo( cfcatch.type & " " & cfcatch.message ); } \ No newline at end of file