Re: [cgi-devel] post data with illegal characters
Status: Beta
Brought to you by:
drrngrvy
From: Darren G. <lis...@gm...> - 2011-01-12 01:26:09
|
Hi Guys, Just following this up - are you able to reproduce this? The function described below should be redundant since the problem is most likely in the CGI library. I'm wondering if this is coming from reusing an fcgi::request object without calling fcgi::request::clear() between requests? As I mentioned, if you can respond with a minimal example that exhibits the behaviour I can take a look. Cheers, Darren On 2 November 2010 14:17, Scott Bailey <Ba...@in...> wrote: > There's a defect in that function. The behavior of operations on an > iterator after erase() is undefined. Do NOT get in the habit of using > dead iterators, it will eventually bite you. Also, I think using > isgraph and isalnum is redundant? > > Here's an improvement, BUT I'd be willing to be theres a better way, still. > > void remove_non_graph(std::string& str) > { > std::string::iterator i=str.begin(); > while( i != str.end() ) > { > if( isgraph(*i) ) > ++i; > else > i=str.erase(i); > } > } > > > > > On Tue, Nov 2, 2010 at 6:11 AM, <jc...@ol...> wrote: > >> Hello, > >> > >> Some of my POST variable are been added illegal characters at the end. > >> > >> 1986^@^@^@^@^@ > >> > >> insead of > >> 1986 > > > > APplying the following function: > > void > > remove_non_graph(std::string& str) > > { > > for(std::string::iterator i=str.end()-1; i>=str.begin(); --i) > > { > > if ( !isalnum(*i) && !isgraph(*i) ) > > { > > str.erase(i); > > } > > } > > } > > to a variable fixes the issue. > > > > Do you think this is a solid patch? > > If so, where in the source codes, should I add it so that all the > > variables are cleaned this way? > > > > Thanks! > > > >> > >> to read those data I am using: > >> > >> for(typename Map::const_iterator i = m.begin(); i != m.end(); ++i) > >> { > >> os << i->first << " = " << i->second << "\n"; > >> } > >> and > >> > >> req.post.pick("task","default"); > >> > >> with the illegal characters been added in both cases. > >> > >>>From the html, I don't see any reason why that would happen. > >> > >> Any idea on how I could fix this problem? > >> > >> Thanks you > >> > >> > >> > ------------------------------------------------------------------------------ > >> Nokia and AT&T present the 2010 Calling All Innovators-North America > >> contest > >> Create new apps & games for the Nokia N8 for consumers in U.S. and > Canada > >> $10 million total in prizes - $4M cash, 500 devices, nearly $6M in > >> marketing > >> Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store > >> http://p.sf.net/sfu/nokia-dev2dev > >> _______________________________________________ > >> cgi-devel mailing list > >> cgi...@li... > >> https://lists.sourceforge.net/lists/listinfo/cgi-devel > >> > > > > > > > > > ------------------------------------------------------------------------------ > > Nokia and AT&T present the 2010 Calling All Innovators-North America > contest > > Create new apps & games for the Nokia N8 for consumers in U.S. and > Canada > > $10 million total in prizes - $4M cash, 500 devices, nearly $6M in > marketing > > Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store > > http://p.sf.net/sfu/nokia-dev2dev > > _______________________________________________ > > cgi-devel mailing list > > cgi...@li... > > https://lists.sourceforge.net/lists/listinfo/cgi-devel > > > > > > -- > Scott Bailey > > > ------------------------------------------------------------------------------ > Nokia and AT&T present the 2010 Calling All Innovators-North America > contest > Create new apps & games for the Nokia N8 for consumers in U.S. and Canada > $10 million total in prizes - $4M cash, 500 devices, nearly $6M in > marketing > Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store > http://p.sf.net/sfu/nokia-dev2dev > _______________________________________________ > cgi-devel mailing list > cgi...@li... > https://lists.sourceforge.net/lists/listinfo/cgi-devel > |