Discussion:
[FreeMarker-user] disableCanonicalPathCheck and spring framework
Mario Gzuk
2016-06-03 11:46:49 UTC
Permalink
Hi,
maybe a simple question, but I cant find a solution how to set
disableCanonicalPathCheck for freemarker in conclusion with the spring
framework. I found a lot of documentation about how to configure it,
e.g.
http://docs.spring.io/autorepo/docs/spring/current/javadoc-api/org/springframework/web/servlet/view/freemarker/FreeMarkerConfigurer.html

but I cant find anything about the disableCanonicalPathCheck. Maybe you
can tell me how to do that, or just say that I have to ask the sping
developer.

Thank you!

Regards Mario
Daniel Dekany
2016-06-03 17:23:03 UTC
Permalink
I think you can only set it if you specify a TemplateLoader object
directly, instead of using the templateLoaderPaths (where you are
using String-s). That can be achieved by setting the
preTemplateLoaders or postTemplateLoaders property of any
FreeMarkerConfigurationFactory subclass.
Post by Mario Gzuk
Hi,
maybe a simple question, but I cant find a solution how to set
disableCanonicalPathCheck for freemarker in conclusion with the spring
framework. I found a lot of documentation about how to configure it,
e.g.
http://docs.spring.io/autorepo/docs/spring/current/javadoc-api/org/springframework/web/servlet/view/freemarker/FreeMarkerConfigurer.html
--
Thanks,
Daniel Dekany
Mario Gzuk
2016-06-03 18:25:29 UTC
Permalink
Hi Daniel,
thank you for this fast answer. I am very new to this, so excuse me if I
ask you for an example for this. Is it possible for you to show me an
example or point me to a documentation about this? The people which I am
asking for it say it is too complicated, or it is not possible to do it
in any way...

Regards Mario
Post by Daniel Dekany
I think you can only set it if you specify a TemplateLoader object
directly, instead of using the templateLoaderPaths (where you are
using String-s). That can be achieved by setting the
preTemplateLoaders or postTemplateLoaders property of any
FreeMarkerConfigurationFactory subclass.
Post by Mario Gzuk
Hi,
maybe a simple question, but I cant find a solution how to set
disableCanonicalPathCheck for freemarker in conclusion with the spring
framework. I found a lot of documentation about how to configure it,
e.g.
http://docs.spring.io/autorepo/docs/spring/current/javadoc-api/org/springframework/web/servlet/view/freemarker/FreeMarkerConfigurer.html
Daniel Dekany
2016-06-04 07:59:29 UTC
Permalink
What do you have so far, or where do you stuck? I suppose you are
creating a FreeMarkerConfigurer somewhere. In a Java config? Then
perhaps you will have something like this:

@Bean FreeMarkerConfigurer freeMarkerConfigurer() {
FreeMarkerConfigurer fmc = new FreeMarkerConfigurer();
...
fmc.setPreTemplateLoaders(new FileTemplateLoader(templatesDir, true));
...
}

But I'm not sure if you really should use a FileTemplateLoader at all.
What's the use case? Why's disableCanonicalPathCheck needed?


BTW, where did you find this retired mailing list address? Both
http://freemarker.org/mailing-lists.html and
https://sourceforge.net/p/freemarker/mailman/?source=navbar says that
this list is retired, yet most people still uses this instead of
***@freemarker.incubator.apache.org. I just want to know if we have
some links left without retirement notice or something.
Post by Mario Gzuk
Hi Daniel,
thank you for this fast answer. I am very new to this, so excuse me if I
ask you for an example for this. Is it possible for you to show me an
example or point me to a documentation about this? The people which I am
asking for it say it is too complicated, or it is not possible to do it
in any way...
Regards Mario
Post by Daniel Dekany
I think you can only set it if you specify a TemplateLoader object
directly, instead of using the templateLoaderPaths (where you are
using String-s). That can be achieved by setting the
preTemplateLoaders or postTemplateLoaders property of any
FreeMarkerConfigurationFactory subclass.
Post by Mario Gzuk
Hi,
maybe a simple question, but I cant find a solution how to set
disableCanonicalPathCheck for freemarker in conclusion with the spring
framework. I found a lot of documentation about how to configure it,
e.g.
http://docs.spring.io/autorepo/docs/spring/current/javadoc-api/org/springframework/web/servlet/view/freemarker/FreeMarkerConfigurer.html
--
Thanks,
Daniel Dekany
Mario Gzuk
2016-06-04 08:51:56 UTC
Permalink
Hi Daniel,
we have a setup mixed with html files and a tomcat app behind a
loadbalancer. The tomcat app is located:
/var/www/DOMAIN/WEB-INF
the apache root is
/var/www/html (symlink to nfs share /mnt/nfs)
and the tomcat is symlinked into that directory:
/var/www/html/DOMAIN/WEB-INF -> /var/www/DOMAIN/WEB-INF
because the tomcat webapp should be only local on every host, that we
can test an webapp update on a single host.
The templates are located in /var/www/DOMAIN/WEB-INF/views.

For now the solution is that we do a bind mount:
mount -o bind /var/www/DOMAIN/WEB-INF /var/www/html/DOMAIN/WEB-INF

but this is not what we want. The app should be able to be configured as
you described below. So that we can define that the templates are
located on a path so that the no symlink check will not be needed.

BTW:
I found the mailing list some where on the main site and did not read it
carfully. So sorry for that. I will go off here now and asking over the
apache next time.

Thank you for your time! I will try to inform you if I can solve our
problem in this way.

Regards Mario
Post by Daniel Dekany
What do you have so far, or where do you stuck? I suppose you are
creating a FreeMarkerConfigurer somewhere. In a Java config? Then
@Bean FreeMarkerConfigurer freeMarkerConfigurer() {
FreeMarkerConfigurer fmc = new FreeMarkerConfigurer();
...
fmc.setPreTemplateLoaders(new FileTemplateLoader(templatesDir, true));
...
}
But I'm not sure if you really should use a FileTemplateLoader at all.
What's the use case? Why's disableCanonicalPathCheck needed?
BTW, where did you find this retired mailing list address? Both
http://freemarker.org/mailing-lists.html and
https://sourceforge.net/p/freemarker/mailman/?source=navbar says that
this list is retired, yet most people still uses this instead of
some links left without retirement notice or something.
Post by Mario Gzuk
Hi Daniel,
thank you for this fast answer. I am very new to this, so excuse me if I
ask you for an example for this. Is it possible for you to show me an
example or point me to a documentation about this? The people which I am
asking for it say it is too complicated, or it is not possible to do it
in any way...
Regards Mario
Post by Daniel Dekany
I think you can only set it if you specify a TemplateLoader object
directly, instead of using the templateLoaderPaths (where you are
using String-s). That can be achieved by setting the
preTemplateLoaders or postTemplateLoaders property of any
FreeMarkerConfigurationFactory subclass.
Post by Mario Gzuk
Hi,
maybe a simple question, but I cant find a solution how to set
disableCanonicalPathCheck for freemarker in conclusion with the spring
framework. I found a lot of documentation about how to configure it,
e.g.
http://docs.spring.io/autorepo/docs/spring/current/javadoc-api/org/springframework/web/servlet/view/freemarker/FreeMarkerConfigurer.html
Loading...