Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Invalid characters in included filename?

Quote Reply
Invalid characters in included filename?
I am trying to create a new set of dynamic pages that includes a certain numbered html file (issuex.htm), based on a parameter passed to the page.cgi template.

I have the code below in the template:
Code:
<%set fileloc = "/home/user/public_html/newsletter/issue$issue.htm"%>
<%include $fileloc%>
Which produces an error:

Error: Can't load included file '/home/user/public_html/newsletter/issue1.htm': Invalid characters in filename

The <%fileloc%> variable in the template dump looks fine to me...I can't work out why this won't work. If I manually put the path in the include line it works fine too. I have tried escaping various parts of the filename with no success either Frown.
Quote Reply
Re: [aus_dave] Invalid characters in included filename? In reply to
For security purposes, when you use variables for an include, the filename cannot contain / (ie. it cannot be a relative or absolute path).

Adrian
Quote Reply
Re: [brewt] Invalid characters in included filename? In reply to
OK, is there a solution to this without hacking the core code? The only part that is variable is the <%issue%> number, so is there some way of including that to the path and leaving the rest as static text?
Quote Reply
Re: [aus_dave] Invalid characters in included filename? In reply to
Either you write a global that does the include (use GT::Template to parse it if needed), or another way would be to add the newsletter directory as a inherited template directory and do just reference it as issue$i.htm.

Adrian
Quote Reply
Re: [brewt] Invalid characters in included filename? In reply to
Thanks for those suggestions Adrian - I found the line in the code where this security check occurs and just removed the restriction on '/'. If it comes unstuck with a future upgrade I'll redo it the proper way.