[SOLVED] CGCalendar, link sets some text into form field?

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3497
Joined: Mon Nov 28, 2011 9:29 am

Re: CGCalendar, link sets some text into form field?

Post by velden »

thomahawk wrote:Now to the security!

I assume one could send anything with such a link, maybe some php injection?

Velden mentioned: "Note that using parameters (get or post) should be validated before actually using them (for security reasons)."

But now, how can I do that validation?
I recently used this call for a module. But I'm not sure if that is safe enough as the variable is already used in a smarty call itself...

Code: Select all

{ModuleName param="/xxx/{$smarty.get.urlparam|regex_replace:'#[^a-zA-Z0-9/_\- ]#':''}"}
Idea of regex_replace above is to remove any character not being space, underscore, hyphen, digit or a-zA-Z
JohnnyB
Dev Team Member
Dev Team Member
Posts: 731
Joined: Tue Nov 21, 2006 5:05 pm

Re: CGCalendar, link sets some text into form field?

Post by JohnnyB »

thomahawk wrote:Now to the security!
Yes, it is best practice to sanitize and validate the expected results.
To sanitize you could use Smarty modifiers like |strip_tags and |htmlspecialchars to remove any HTML, JS, PHP tags from the string and to turn any characters like <,>, and others into their special character equivalents.

To validate, it would take some REGEX to check if the value is what you expect it to be. For example, the event name would only contain characters a to z and 0 to 9 and maybe you will allow an ! or a " in the name. So, regex would be used to check that.

For example, this would allow letters, numbers, and spaces, and underscores too I think... But, it will depend upon the character encoding and language for your site....

^[\w ]+$

-- Others may have more suggestions --
"The art of life lies in a constant readjustment to our surroundings." -Okakura Kakuzo

--
LinkedIn profile
--
I only speak/write in English so I may not translate well on International posts.
--
User avatar
thomahawk
Power Poster
Power Poster
Posts: 312
Joined: Fri Jul 25, 2008 10:13 am

Re: CGCalendar, link sets some text into form field?

Post by thomahawk »

Thank you JohnnyB and Velden. So I suppose this should make it safe enough
{FormBuilder form='anmeldeformular' value_fld43=$smarty.get.event|strip_tags}

Anyway, it seems whatever is passed along with the URL, if it survives the strip_tags, it does nothing else but being displayed in the formfield.

Regards,
Thom
Post Reply

Return to “Modules/Add-Ons”