[zypp-devel] Re: [zypp-commit] r10158 - in /trunk/libzypp/zypp: RepoManager.cc target/rpm/RpmDb.cc
jreidinger@svn.opensuse.org wrote:
Author: jreidinger Date: Tue May 20 12:11:28 2008 New Revision: 10158
URL: http://svn.opensuse.org/viewcvs/zypp?rev=10158&view=rev Log: allow installation and refresh from repository with alias that contains ' or " (bnc #392426)
Pozri RepoInfo::escaped_alias(), nebolo by lepsie to hacknut do neho?
Modified: trunk/libzypp/zypp/RepoManager.cc trunk/libzypp/zypp/target/rpm/RpmDb.cc
Modified: trunk/libzypp/zypp/RepoManager.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/RepoManager.cc?rev=10158&r1=10157&r2=10158&view=diff ============================================================================== --- trunk/libzypp/zypp/RepoManager.cc (original) +++ trunk/libzypp/zypp/RepoManager.cc Tue May 20 12:11:28 2008 @@ -772,12 +772,17 @@ ManagedFile guard( solvfile, filesystem::unlink );
ostringstream cmd; + const char *toFile = str::gsub(solvfile.asString(),"\"","\\\"").c_str(); if ( repokind.toEnum() == RepoType::RPMPLAINDIR_e ) { - cmd << str::form( "repo2solv.sh \"%s\" > \"%s\"", info.baseUrlsBegin()->getPathName().c_str(), solvfile.c_str() ); + const char * from = str::gsub( + info.baseUrlsBegin()->getPathName(),"\"","\\\"").c_str(); + cmd << str::form( "repo2solv.sh \"%s\" > \"%s\"", from , toFile ); } else - cmd << str::form( "repo2solv.sh \"%s\" > \"%s\"", rawpath.c_str(), solvfile.c_str() ); - + { + const char * from = str::gsub(rawpath.asString(),"\"","\\\"").c_str(); + cmd << str::form( "repo2solv.sh \"%s\" > \"%s\"", from, toFile ); + } MIL << "Executing: " << cmd.str() << endl; ExternalProgram prog( cmd.str(), ExternalProgram::Stderr_To_Stdout );
Modified: trunk/libzypp/zypp/target/rpm/RpmDb.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/target/rpm/RpmDb.cc?rev=10158&r1=10157&r2=10158&view=diff ============================================================================== --- trunk/libzypp/zypp/target/rpm/RpmDb.cc (original) +++ trunk/libzypp/zypp/target/rpm/RpmDb.cc Tue May 20 12:11:28 2008 @@ -57,7 +57,7 @@ { namespace { -const char* quoteInFilename_m = " \t"; +const char* quoteInFilename_m = " \t\'\""; inline string rpmQuoteFilename( const Pathname & path_r ) { string path( path_r.asString() );
-- To unsubscribe, e-mail: zypp-devel+unsubscribe@opensuse.org For additional commands, e-mail: zypp-devel+help@opensuse.org
Jan Kupec wrote:
jreidinger@svn.opensuse.org wrote:
Author: jreidinger Date: Tue May 20 12:11:28 2008 New Revision: 10158
URL: http://svn.opensuse.org/viewcvs/zypp?rev=10158&view=rev Log: allow installation and refresh from repository with alias that contains ' or " (bnc #392426)
Pozri RepoInfo::escaped_alias(), nebolo by lepsie to hacknut do neho?
Sorry, i meant to send it to Pepa only :O) It says whether it wouldn't be better to fix this in the escaped_alias() method. cheers, jano -- To unsubscribe, e-mail: zypp-devel+unsubscribe@opensuse.org For additional commands, e-mail: zypp-devel+help@opensuse.org
Date: Tue May 20 12:11:28 2008 New Revision: 10158 URL: http://svn.opensuse.org/viewcvs/zypp?rev=10158&view=rev Log: allow installation and refresh from repository with alias that contains ' or " (bnc #392426)
+ const char *toFile = str::gsub(solvfile.asString(),"\"","\\\"").c_str(); if ( repokind.toEnum() == RepoType::RPMPLAINDIR_e ) { - cmd << str::form( "repo2solv.sh \"%s\" > \"%s\"", info.baseUrlsBegin()->getPathName().c_str(), solvfile.c_str() ); + const char * from = str::gsub( + info.baseUrlsBegin()->getPathName(),"\"","\\\"").c_str(); + cmd << str::form( "repo2solv.sh \"%s\" > \"%s\"", from , toFile );
const char *toFile = str::gsub(...).c_str(); Is IMO not efficient but undefined behaviour! c_str() returns a pointer to the std::strings internal data. Any string manipulation (incl. going out of scope) may invalidate the char*. std::strings are cheap to copy and .c_str() is most probably inlined, so you don't lose performance if you take care the string actually stays in memory: std::string toFile = str::gsub(..); or better std::string toFile( str::gsub(..) ); Otherwise you have to do it this way: cmd << str::form( "repo2solv.sh \"%s\" > \"%s\"", str::gsub( info.baseUrlsBegin()->getPathName(),"\"","\\\"").c_str(), str::gsub( solvfile.asString(),"\"","\\\"").c_str() ); (I'll fix it) -- cu, Michael Andres +------------------------------------------------------------------+ Key fingerprint = 2DFA 5D73 18B1 E7EF A862 27AC 3FB8 9E3A 27C6 B0E4 +------------------------------------------------------------------+ Michael Andres YaST Development ma@novell.com SUSE LINUX Products GmbH, GF: Markus Rex, HRB 16746 (AG Nuernberg) Maxfeldstrasse 5, D-90409 Nuernberg, Germany, ++49 (0)911 - 740 53-0 +------------------------------------------------------------------+ -- To unsubscribe, e-mail: zypp-devel+unsubscribe@opensuse.org For additional commands, e-mail: zypp-devel+help@opensuse.org
Michael Andres wrote:
Date: Tue May 20 12:11:28 2008 New Revision: 10158 URL: http://svn.opensuse.org/viewcvs/zypp?rev=10158&view=rev Log: allow installation and refresh from repository with alias that contains ' or " (bnc #392426)
+ const char *toFile = str::gsub(solvfile.asString(),"\"","\\\"").c_str(); if ( repokind.toEnum() == RepoType::RPMPLAINDIR_e ) { - cmd << str::form( "repo2solv.sh \"%s\" > \"%s\"", info.baseUrlsBegin()->getPathName().c_str(), solvfile.c_str() ); + const char * from = str::gsub( + info.baseUrlsBegin()->getPathName(),"\"","\\\"").c_str(); + cmd << str::form( "repo2solv.sh \"%s\" > \"%s\"", from , toFile );
const char *toFile = str::gsub(...).c_str();
Is IMO not efficient but undefined behaviour!
c_str() returns a pointer to the std::strings internal data. Any string manipulation (incl. going out of scope) may invalidate the char*.
std::strings are cheap to copy and .c_str() is most probably inlined, so you don't lose performance if you take care the string actually stays in memory:
std::string toFile = str::gsub(..); or better std::string toFile( str::gsub(..) );
Otherwise you have to do it this way:
cmd << str::form( "repo2solv.sh \"%s\" > \"%s\"", str::gsub( info.baseUrlsBegin()->getPathName(),"\"","\\\"").c_str(), str::gsub( solvfile.asString(),"\"","\\\"").c_str() );
(I'll fix it)
Thanks for fix, I little overdo elimination of duplicate code. Pepa -- To unsubscribe, e-mail: zypp-devel+unsubscribe@opensuse.org For additional commands, e-mail: zypp-devel+help@opensuse.org
participants (3)
-
Jan Kupec
-
Josef Reidinger
-
Michael Andres