Part of the EllisLab Network
   
 
input class post method change
Posted: 20 June 2009 07:09 AM   [ Ignore ]  
Sr. Research Associate
RankRankRankRankRank
Total Posts:  4839
Joined  07-14-2006

I just read this thread and i had a led moment, ecology before everything wink

Why not open the second parameter to other input altering methods/functions, now you can only xss clean the input.

So if you want to xss clean it you would have to do

$this->input->post('some_key','xss_clean');

But then you also can add other functions like

$this->input->post('some_key','trim|ucwords');

It’s not a big change but i think it could benefit some developers.

Profile
 
 
Posted: 20 June 2009 08:35 AM   [ Ignore ]   [ # 1 ]  
Sr. Research Associate
Avatar
RankRankRankRankRank
Total Posts:  2690
Joined  05-18-2008

That is a good idea smile
And it should be fairly easy to implement while maintaining backwards compatability, as you just check is it’s a bool, in which case you process it as it currently is, otherwise, it’s a string, so call each function in turn, like with the validation class

Edit: Just thought of a potential problem
What if you have global XSS cleaning enabled, but you have a particular post value you don’t want cleaned? Normally you could just pass in false (I’m assuming that would currently override the global?). Any ideas how to get around this if you don’t want xss_clean, but do wat some other calls, such as trim etc

 Signature 

I’m building a Project Management System for my 3rd year Uni project, Sign up to the beta
Track my progress | Post of the day: UI Designs
Get full auto complete support for CodeIgniter in Eclipse

Profile
 
 
Posted: 20 June 2009 09:43 AM   [ Ignore ]   [ # 2 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  202
Joined  12-31-2007

You could keep the 2nd param as a bool for xss_clean and make the feature request the 3rd param

-or-

Add an option that would turn xss_clean off, such as

$this->input->post('some_key','xss_clean_off|trim|ucwords');
Profile
 
 
Posted: 20 June 2009 03:10 PM   [ Ignore ]   [ # 3 ]  
Sr. Research Associate
RankRankRankRankRank
Total Posts:  4839
Joined  07-14-2006

If the global cleaning is enabled it kicks in as soon as the input class is loaded so the method as it is doesn’t overwrite the global cleaning either. It’s a change I requested a while ago.

They could keep the boolean but i think the preferred way should be to add the method/function name because it’s easier to know what the parameter does then.

simshaun your ideas add too much crud to the method. The second parameter already is input altering and if you call the method without the second parameter it won’t clean the value. Adding xss_clean_off will make the method more complex as it is a switch instead of a function.

Profile
 
 
Posted: 20 June 2009 03:14 PM   [ Ignore ]   [ # 4 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  202
Joined  12-31-2007

Hell.. I was just throwing ideas out there, not trying to crud the method up. I dont know and haven’t even looked at how the form_validation lib handles the rules.

Profile
 
 
   
 
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 819, on March 11, 2010 11:15 AM
Total Registered Members: 120378 Total Logged-in Users: 19
Total Topics: 126497 Total Anonymous Users: 5
Total Replies: 665221 Total Guests: 281
Total Posts: 791718    
Members ( View Memberlist )