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

davsclaus pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/master by this push:
     new 16742a7  CAMEL-16311: camel-freemarker - Localized lookup should be 
disabled
16742a7 is described below

commit 16742a7fce3a9a3bf32f33bb022693546df4b2a4
Author: Claus Ibsen <claus.ib...@gmail.com>
AuthorDate: Sat Mar 6 15:38:28 2021 +0100

    CAMEL-16311: camel-freemarker - Localized lookup should be disabled
---
 .../camel/catalog/docs/freemarker-component.adoc      |  3 ++-
 .../freemarker/FreemarkerComponentConfigurer.java     |  6 ++++++
 .../apache/camel/component/freemarker/freemarker.json |  1 +
 .../src/main/docs/freemarker-component.adoc           |  3 ++-
 .../component/freemarker/FreemarkerComponent.java     | 19 ++++++++++++++++---
 .../dsl/FreemarkerComponentBuilderFactory.java        | 17 +++++++++++++++++
 .../modules/ROOT/pages/freemarker-component.adoc      |  3 ++-
 .../ROOT/pages/camel-3x-upgrade-guide-3_9.adoc        |  8 +++++++-
 8 files changed, 53 insertions(+), 7 deletions(-)

diff --git 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/freemarker-component.adoc
 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/freemarker-component.adoc
index 3c018c8..3dbb9b0 100644
--- 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/freemarker-component.adoc
+++ 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/freemarker-component.adoc
@@ -49,7 +49,7 @@ You can append query options to the URI in the following 
format,
 
 
 // component options: START
-The Freemarker component supports 5 options, which are listed below.
+The Freemarker component supports 6 options, which are listed below.
 
 
 
@@ -59,6 +59,7 @@ The Freemarker component supports 5 options, which are listed 
below.
 | *allowContextMapAll* (producer) | Sets whether the context map should allow 
access to all details. By default only the message body and headers can be 
accessed. This option can be enabled for full access to the current Exchange 
and CamelContext. Doing so impose a potential security risk as this opens 
access to the full power of CamelContext API. | false | boolean
 | *allowTemplateFromHeader* (producer) | Whether to allow to use resource 
template from header or not (default false). Enabling this allows to specify 
dynamic templates via message header. However this can be seen as a potential 
security vulnerability if the header is coming from a malicious user, so use 
this with care. | false | boolean
 | *lazyStartProducer* (producer) | Whether the producer should be started lazy 
(on the first message). By starting lazy you can use this to allow CamelContext 
and routes to startup in situations where a producer may otherwise fail during 
starting and cause the route to fail being started. By deferring this startup 
to be lazy then the startup failure can be handled during routing messages via 
Camel's routing error handlers. Beware that when the first message is processed 
then creating and [...]
+| *localizedLookup* (producer) | Enables/disables localized template lookup. 
Disabled by default. | false | boolean
 | *autowiredEnabled* (advanced) | Whether autowiring is enabled. This is used 
for automatic autowiring options (the option must be marked as autowired) by 
looking up in the registry to find if there is a single instance of matching 
type, which then gets configured on the component. This can be used for 
automatic configuring JDBC data sources, JMS connection factories, AWS Clients, 
etc. | true | boolean
 | *configuration* (advanced) | To use an existing 
freemarker.template.Configuration instance as the configuration. |  | 
Configuration
 |===
diff --git 
a/components/camel-freemarker/src/generated/java/org/apache/camel/component/freemarker/FreemarkerComponentConfigurer.java
 
b/components/camel-freemarker/src/generated/java/org/apache/camel/component/freemarker/FreemarkerComponentConfigurer.java
index 5d66088..e251234 100644
--- 
a/components/camel-freemarker/src/generated/java/org/apache/camel/component/freemarker/FreemarkerComponentConfigurer.java
+++ 
b/components/camel-freemarker/src/generated/java/org/apache/camel/component/freemarker/FreemarkerComponentConfigurer.java
@@ -30,6 +30,8 @@ public class FreemarkerComponentConfigurer extends 
PropertyConfigurerSupport imp
         case "configuration": target.setConfiguration(property(camelContext, 
freemarker.template.Configuration.class, value)); return true;
         case "lazystartproducer":
         case "lazyStartProducer": 
target.setLazyStartProducer(property(camelContext, boolean.class, value)); 
return true;
+        case "localizedlookup":
+        case "localizedLookup": 
target.setLocalizedLookup(property(camelContext, boolean.class, value)); return 
true;
         default: return false;
         }
     }
@@ -46,6 +48,8 @@ public class FreemarkerComponentConfigurer extends 
PropertyConfigurerSupport imp
         case "configuration": return freemarker.template.Configuration.class;
         case "lazystartproducer":
         case "lazyStartProducer": return boolean.class;
+        case "localizedlookup":
+        case "localizedLookup": return boolean.class;
         default: return null;
         }
     }
@@ -63,6 +67,8 @@ public class FreemarkerComponentConfigurer extends 
PropertyConfigurerSupport imp
         case "configuration": return target.getConfiguration();
         case "lazystartproducer":
         case "lazyStartProducer": return target.isLazyStartProducer();
+        case "localizedlookup":
+        case "localizedLookup": return target.isLocalizedLookup();
         default: return null;
         }
     }
diff --git 
a/components/camel-freemarker/src/generated/resources/org/apache/camel/component/freemarker/freemarker.json
 
b/components/camel-freemarker/src/generated/resources/org/apache/camel/component/freemarker/freemarker.json
index d0fd535..2cdf907 100644
--- 
a/components/camel-freemarker/src/generated/resources/org/apache/camel/component/freemarker/freemarker.json
+++ 
b/components/camel-freemarker/src/generated/resources/org/apache/camel/component/freemarker/freemarker.json
@@ -25,6 +25,7 @@
     "allowContextMapAll": { "kind": "property", "displayName": "Allow Context 
Map All", "group": "producer", "label": "", "required": false, "type": 
"boolean", "javaType": "boolean", "deprecated": false, "autowired": false, 
"secret": false, "defaultValue": false, "description": "Sets whether the 
context map should allow access to all details. By default only the message 
body and headers can be accessed. This option can be enabled for full access to 
the current Exchange and CamelContext.  [...]
     "allowTemplateFromHeader": { "kind": "property", "displayName": "Allow 
Template From Header", "group": "producer", "label": "", "required": false, 
"type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": 
false, "secret": false, "defaultValue": false, "description": "Whether to allow 
to use resource template from header or not (default false). Enabling this 
allows to specify dynamic templates via message header. However this can be 
seen as a potential security vulne [...]
     "lazyStartProducer": { "kind": "property", "displayName": "Lazy Start 
Producer", "group": "producer", "label": "producer", "required": false, "type": 
"boolean", "javaType": "boolean", "deprecated": false, "autowired": false, 
"secret": false, "defaultValue": false, "description": "Whether the producer 
should be started lazy (on the first message). By starting lazy you can use 
this to allow CamelContext and routes to startup in situations where a producer 
may otherwise fail during star [...]
+    "localizedLookup": { "kind": "property", "displayName": "Localized 
Lookup", "group": "producer", "label": "", "required": false, "type": 
"boolean", "javaType": "boolean", "deprecated": false, "autowired": false, 
"secret": false, "defaultValue": false, "description": "Enables\/disables 
localized template lookup. Disabled by default." },
     "autowiredEnabled": { "kind": "property", "displayName": "Autowired 
Enabled", "group": "advanced", "label": "advanced", "required": false, "type": 
"boolean", "javaType": "boolean", "deprecated": false, "autowired": false, 
"secret": false, "defaultValue": true, "description": "Whether autowiring is 
enabled. This is used for automatic autowiring options (the option must be 
marked as autowired) by looking up in the registry to find if there is a single 
instance of matching type, which t [...]
     "configuration": { "kind": "property", "displayName": "Configuration", 
"group": "advanced", "label": "advanced", "required": false, "type": "object", 
"javaType": "freemarker.template.Configuration", "deprecated": false, 
"autowired": false, "secret": false, "description": "To use an existing 
freemarker.template.Configuration instance as the configuration." }
   },
diff --git 
a/components/camel-freemarker/src/main/docs/freemarker-component.adoc 
b/components/camel-freemarker/src/main/docs/freemarker-component.adoc
index 3c018c8..3dbb9b0 100644
--- a/components/camel-freemarker/src/main/docs/freemarker-component.adoc
+++ b/components/camel-freemarker/src/main/docs/freemarker-component.adoc
@@ -49,7 +49,7 @@ You can append query options to the URI in the following 
format,
 
 
 // component options: START
-The Freemarker component supports 5 options, which are listed below.
+The Freemarker component supports 6 options, which are listed below.
 
 
 
@@ -59,6 +59,7 @@ The Freemarker component supports 5 options, which are listed 
below.
 | *allowContextMapAll* (producer) | Sets whether the context map should allow 
access to all details. By default only the message body and headers can be 
accessed. This option can be enabled for full access to the current Exchange 
and CamelContext. Doing so impose a potential security risk as this opens 
access to the full power of CamelContext API. | false | boolean
 | *allowTemplateFromHeader* (producer) | Whether to allow to use resource 
template from header or not (default false). Enabling this allows to specify 
dynamic templates via message header. However this can be seen as a potential 
security vulnerability if the header is coming from a malicious user, so use 
this with care. | false | boolean
 | *lazyStartProducer* (producer) | Whether the producer should be started lazy 
(on the first message). By starting lazy you can use this to allow CamelContext 
and routes to startup in situations where a producer may otherwise fail during 
starting and cause the route to fail being started. By deferring this startup 
to be lazy then the startup failure can be handled during routing messages via 
Camel's routing error handlers. Beware that when the first message is processed 
then creating and [...]
+| *localizedLookup* (producer) | Enables/disables localized template lookup. 
Disabled by default. | false | boolean
 | *autowiredEnabled* (advanced) | Whether autowiring is enabled. This is used 
for automatic autowiring options (the option must be marked as autowired) by 
looking up in the registry to find if there is a single instance of matching 
type, which then gets configured on the component. This can be used for 
automatic configuring JDBC data sources, JMS connection factories, AWS Clients, 
etc. | true | boolean
 | *configuration* (advanced) | To use an existing 
freemarker.template.Configuration instance as the configuration. |  | 
Configuration
 |===
diff --git 
a/components/camel-freemarker/src/main/java/org/apache/camel/component/freemarker/FreemarkerComponent.java
 
b/components/camel-freemarker/src/main/java/org/apache/camel/component/freemarker/FreemarkerComponent.java
index 2f14bdf..81a14e9 100644
--- 
a/components/camel-freemarker/src/main/java/org/apache/camel/component/freemarker/FreemarkerComponent.java
+++ 
b/components/camel-freemarker/src/main/java/org/apache/camel/component/freemarker/FreemarkerComponent.java
@@ -35,10 +35,12 @@ import org.apache.camel.util.ObjectHelper;
 @Component("freemarker")
 public class FreemarkerComponent extends DefaultComponent {
 
-    @Metadata(defaultValue = "false")
+    @Metadata
     private boolean allowTemplateFromHeader;
-    @Metadata(defaultValue = "false")
+    @Metadata
     private boolean allowContextMapAll;
+    @Metadata
+    private boolean localizedLookup;
     @Metadata(label = "advanced")
     private Configuration configuration;
     private Configuration noCacheConfiguration;
@@ -86,7 +88,7 @@ public class FreemarkerComponent extends DefaultComponent {
     public synchronized Configuration getConfiguration() {
         if (configuration == null) {
             configuration = new 
Configuration(Configuration.DEFAULT_INCOMPATIBLE_IMPROVEMENTS);
-            configuration.setLocalizedLookup(false);
+            configuration.setLocalizedLookup(isLocalizedLookup());
             configuration.setTemplateLoader(new URLTemplateLoader() {
                 @Override
                 protected URL getURL(String name) {
@@ -137,6 +139,17 @@ public class FreemarkerComponent extends DefaultComponent {
         this.allowContextMapAll = allowContextMapAll;
     }
 
+    public boolean isLocalizedLookup() {
+        return localizedLookup;
+    }
+
+    /**
+     * Enables/disables localized template lookup. Disabled by default.
+     */
+    public void setLocalizedLookup(boolean localizedLookup) {
+        this.localizedLookup = localizedLookup;
+    }
+
     private synchronized Configuration getNoCacheConfiguration() {
         if (noCacheConfiguration == null) {
             // create a clone of the regular configuration
diff --git 
a/core/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/FreemarkerComponentBuilderFactory.java
 
b/core/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/FreemarkerComponentBuilderFactory.java
index c072571..db86b25 100644
--- 
a/core/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/FreemarkerComponentBuilderFactory.java
+++ 
b/core/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/FreemarkerComponentBuilderFactory.java
@@ -115,6 +115,22 @@ public interface FreemarkerComponentBuilderFactory {
             return this;
         }
         /**
+         * Enables/disables localized template lookup. Disabled by default.
+         * 
+         * The option is a: &lt;code&gt;boolean&lt;/code&gt; type.
+         * 
+         * Default: false
+         * Group: producer
+         * 
+         * @param localizedLookup the value to set
+         * @return the dsl builder
+         */
+        default FreemarkerComponentBuilder localizedLookup(
+                boolean localizedLookup) {
+            doSetProperty("localizedLookup", localizedLookup);
+            return this;
+        }
+        /**
          * Whether autowiring is enabled. This is used for automatic autowiring
          * options (the option must be marked as autowired) by looking up in 
the
          * registry to find if there is a single instance of matching type,
@@ -172,6 +188,7 @@ public interface FreemarkerComponentBuilderFactory {
             case "allowContextMapAll": ((FreemarkerComponent) 
component).setAllowContextMapAll((boolean) value); return true;
             case "allowTemplateFromHeader": ((FreemarkerComponent) 
component).setAllowTemplateFromHeader((boolean) value); return true;
             case "lazyStartProducer": ((FreemarkerComponent) 
component).setLazyStartProducer((boolean) value); return true;
+            case "localizedLookup": ((FreemarkerComponent) 
component).setLocalizedLookup((boolean) value); return true;
             case "autowiredEnabled": ((FreemarkerComponent) 
component).setAutowiredEnabled((boolean) value); return true;
             case "configuration": ((FreemarkerComponent) 
component).setConfiguration((freemarker.template.Configuration) value); return 
true;
             default: return false;
diff --git a/docs/components/modules/ROOT/pages/freemarker-component.adoc 
b/docs/components/modules/ROOT/pages/freemarker-component.adoc
index 5244375..b44cb7e 100644
--- a/docs/components/modules/ROOT/pages/freemarker-component.adoc
+++ b/docs/components/modules/ROOT/pages/freemarker-component.adoc
@@ -51,7 +51,7 @@ You can append query options to the URI in the following 
format,
 
 
 // component options: START
-The Freemarker component supports 5 options, which are listed below.
+The Freemarker component supports 6 options, which are listed below.
 
 
 
@@ -61,6 +61,7 @@ The Freemarker component supports 5 options, which are listed 
below.
 | *allowContextMapAll* (producer) | Sets whether the context map should allow 
access to all details. By default only the message body and headers can be 
accessed. This option can be enabled for full access to the current Exchange 
and CamelContext. Doing so impose a potential security risk as this opens 
access to the full power of CamelContext API. | false | boolean
 | *allowTemplateFromHeader* (producer) | Whether to allow to use resource 
template from header or not (default false). Enabling this allows to specify 
dynamic templates via message header. However this can be seen as a potential 
security vulnerability if the header is coming from a malicious user, so use 
this with care. | false | boolean
 | *lazyStartProducer* (producer) | Whether the producer should be started lazy 
(on the first message). By starting lazy you can use this to allow CamelContext 
and routes to startup in situations where a producer may otherwise fail during 
starting and cause the route to fail being started. By deferring this startup 
to be lazy then the startup failure can be handled during routing messages via 
Camel's routing error handlers. Beware that when the first message is processed 
then creating and [...]
+| *localizedLookup* (producer) | Enables/disables localized template lookup. 
Disabled by default. | false | boolean
 | *autowiredEnabled* (advanced) | Whether autowiring is enabled. This is used 
for automatic autowiring options (the option must be marked as autowired) by 
looking up in the registry to find if there is a single instance of matching 
type, which then gets configured on the component. This can be used for 
automatic configuring JDBC data sources, JMS connection factories, AWS Clients, 
etc. | true | boolean
 | *configuration* (advanced) | To use an existing 
freemarker.template.Configuration instance as the configuration. |  | 
Configuration
 |===
diff --git 
a/docs/user-manual/modules/ROOT/pages/camel-3x-upgrade-guide-3_9.adoc 
b/docs/user-manual/modules/ROOT/pages/camel-3x-upgrade-guide-3_9.adoc
index dfd43f4..a0887d6 100644
--- a/docs/user-manual/modules/ROOT/pages/camel-3x-upgrade-guide-3_9.adoc
+++ b/docs/user-manual/modules/ROOT/pages/camel-3x-upgrade-guide-3_9.adoc
@@ -88,4 +88,10 @@ the one to use above, and then add which -starter JARs you 
want to use in your C
 
 === Camel-Azure component
 
-- Camel-Azure has been reomved. Please switch to Camel-Azure-Storage-Blob and 
Camel-Azure-Storage-Queue.
+- Camel-Azure has been removed. Please switch to Camel-Azure-Storage-Blob and 
Camel-Azure-Storage-Queue.
+
+=== camel-freemarker component
+
+The freemarker component now has turned off localized lookup for templates.
+This can be turned back on by setting `localizedLookup=true` on the component.
+

Reply via email to