CVSROOT: /cvsroot/gnash Module name: gnash Changes by: Benjamin Wolsey <bwy> 07/08/23 09:37:23
Modified files: doc/C/usermanual/usage: gnashrc.xml libbase : rc.cpp rc.h Log message: * libbase/rc.{cpp,h}: expandPath called on non-POSIX systems for other path operations. Whitelist and blacklist now space not colon separated. NOTE: Old lists still work, but that behaviour must be deprecated before protocols can be used in lists. Made private: extractSetting, extractNumber. Minor code cleanups. * docs/C/usermanual/usage/gnashrc.xml: add info about black- and whitelists. CVSWeb URLs: http://cvs.savannah.gnu.org/viewcvs/gnash/doc/C/usermanual/usage/gnashrc.xml?cvsroot=gnash&r1=1.8&r2=1.9 http://cvs.savannah.gnu.org/viewcvs/gnash/libbase/rc.cpp?cvsroot=gnash&r1=1.32&r2=1.33 http://cvs.savannah.gnu.org/viewcvs/gnash/libbase/rc.h?cvsroot=gnash&r1=1.24&r2=1.25 Patches: Index: doc/C/usermanual/usage/gnashrc.xml =================================================================== RCS file: /cvsroot/gnash/gnash/doc/C/usermanual/usage/gnashrc.xml,v retrieving revision 1.8 retrieving revision 1.9 diff -u -b -r1.8 -r1.9 --- doc/C/usermanual/usage/gnashrc.xml 20 Aug 2007 17:48:09 -0000 1.8 +++ doc/C/usermanual/usage/gnashrc.xml 23 Aug 2007 09:37:22 -0000 1.9 @@ -54,13 +54,13 @@ <row> <entry>whitelist</entry> <entry>hostnames</entry> -<entry>This is a list of hostnames, separated by a colon (:). If this list is populated, &app; will only load external Flash movies from the specified hosts. The whitelist takes precedence over the blacklist.</entry> +<entry>This is a list of hostnames, separated by spaces. If this list is populated, &app; will only load external Flash movies from the specified hosts. The whitelist takes precedence over the blacklist.</entry> </row> <row> <entry>blacklist</entry> <entry>hostnames</entry> -<entry>This is a list of hostnames, separated by a colon - <emphasis>:</emphasis>. External flash movies from these +<entry>This is a list of hostnames, separated by spaces. + External flash movies from these domains are never allowed to load. If whitelist is present and not empty, blacklist is not used.</entry> </row> @@ -176,10 +176,10 @@ # These sites are OK # uncommenting the following line will allow load of external # movies *only* from the specified hosts. - #set whitelist www.doonesbury.com:www.cnn.com:www.9news.com + #set whitelist www.doonesbury.com www.cnn.com www.9news.com # Don't access content from these sites - set blacklist www.doubleclick.com:mochibot.com + set blacklist www.doubleclick.com mochibot.com # The delay between timer interrupts set delay 50 Index: libbase/rc.cpp =================================================================== RCS file: /cvsroot/gnash/gnash/libbase/rc.cpp,v retrieving revision 1.32 retrieving revision 1.33 diff -u -b -r1.32 -r1.33 --- libbase/rc.cpp 23 Aug 2007 09:26:50 -0000 1.32 +++ libbase/rc.cpp 23 Aug 2007 09:37:22 -0000 1.33 @@ -117,19 +117,21 @@ } bool -RcInitFile::extractSetting(bool *var, const char *pattern, std::string &variable, - std::string &value) +RcInitFile::extractSetting(bool *var, const char *pattern, + std::string &variable, std::string &value) { // GNASH_REPORT_FUNCTION; //log_msg ("%s: %s", variable, value); StringNoCaseEqual noCaseCompare; if ( noCaseCompare(variable, pattern) ) { - if ( noCaseCompare(value, "on") || noCaseCompare(value, "yes") || noCaseCompare(value, "true")) { + if ( noCaseCompare(value, "on") || noCaseCompare(value, "yes") || + noCaseCompare(value, "true")) { //log_msg ("%s: Enabled", variable); *var = true; } - if (noCaseCompare(value, "off") || noCaseCompare(value, "no") || noCaseCompare(value, "false")) { + if (noCaseCompare(value, "off") || noCaseCompare(value, "no") || + noCaseCompare(value, "false")) { //log_msg ("%s: Disabled", variable); *var = false; } @@ -150,45 +152,52 @@ } string -RcInitFile::expandPath (std::string& unixpath) +RcInitFile::expandPath (std::string _path) { -//Don't break build on systems without passwd / getpwnam -string _expanded; +//Returns what's passed to it on systems without +//POSIX tilde expansion, but is still called to prepare +//for other operations on the path string + +#ifdef HAVE_PWD_H +//Don't build tilde expansion on systems without pwd.h //Only if path starts with "~" - if (unixpath.substr(0,1) == "~") { + if (_path.substr(0,1) == "~") { const char *home = getenv("HOME"); - if (unixpath.substr(1,1) == "/") { + if (_path.substr(1,1) == "/") { // Initial "~" followed by "/" if (home) { // if HOME set in env, replace ~ with HOME - _expanded = unixpath.replace(0,1,home); + _path = _path.replace(0,1,home); } -#ifdef HAVE_GETPWNAM +# ifdef HAVE_GETPWNAM +//Don't try this on systems without getpwnam + //HOME not set in env: try using pwd else { struct passwd *password = getpwuid(getuid()); const char *pwdhome = password->pw_dir; - if (home) { _expanded = unixpath.replace(0,1,pwdhome); } + if (home) { + _path = _path.replace(0,1,pwdhome); + } //If all that fails, leave path alone - else _expanded = unixpath; } - } //Initial "~" is not followed by "/" else { const char *userhome = NULL; - string::size_type first_slash = unixpath.find_first_of("/"); + string::size_type first_slash = + _path.find_first_of("/"); string user; if (first_slash != string::npos) { // everything between initial ~ and / - user = unixpath.substr(1, first_slash - 1 ); - } else user = unixpath.substr(1); + user = _path.substr(1, first_slash - 1 ); + } else user = _path.substr(1); //find user using pwd struct passwd *password = getpwnam(user.c_str()); @@ -198,33 +207,14 @@ } if (userhome) { string foundhome(userhome); - _expanded = unixpath.replace(0,first_slash,foundhome); + _path = _path.replace(0,first_slash,foundhome); } - else { - //User not found and/or pwd doesn't return homedir: - //Leave path alone. - _expanded = unixpath; +# endif } } - } - //Path doesn't start with ~, leave it alone. - -#else -//For systems with pwd.h but not getpwnam, nothing to do if HOME not set. - else _expanded = unixpath; - } - else _expanded = unixpath; - } #endif - - else { - _expanded = unixpath; - } - - - - return _expanded; + return _path; } // Parse the config file and set the variables. @@ -272,18 +262,24 @@ // log_msg ("%s %s %s", action, variable, value); if (action == "set") { - extractSetting(&_splash_screen, "splash_screen", variable, value); - extractSetting(&_localhost_only, "localhost", variable, value); - extractSetting(&_localdomain_only, "localdomain", variable, value); + extractSetting(&_splash_screen, "splash_screen", variable, + value); + extractSetting(&_localhost_only, "localhost", variable, + value); + extractSetting(&_localdomain_only, "localdomain", variable, + value); extractSetting(&_debugger, "debugger", variable, value); extractSetting(&_actiondump, "actionDump", variable, value); extractSetting(&_parserdump, "parserDump", variable, value); extractSetting(&_writelog, "writelog", variable, value); extractSetting(&_sound, "sound", variable, value); extractSetting(&_plugin_sound, "pluginsound", variable, value); - extractSetting(&_verboseASCodingErrors, "ASCodingErrorsVerbosity", variable, value); - extractSetting(&_verboseMalformedSWF, "MalformedSWFVerbosity", variable, value); - extractSetting(&_extensionsEnabled, "EnableExtensions", variable, value); + extractSetting(&_verboseASCodingErrors, + "ASCodingErrorsVerbosity", variable, value); + extractSetting(&_verboseMalformedSWF, "MalformedSWFVerbosity", + variable, value); + extractSetting(&_extensionsEnabled, "EnableExtensions", + variable, value); extractSetting(&_startStopped, "StartStopped", variable, value); extractNumber(&_delay, "delay", variable, value); @@ -291,39 +287,54 @@ if (variable == "flashVersionString") { _flashVersionString = value; + continue; } if (variable == "debuglog") { - -#ifdef HAVE_PWD_H _log = expandPath (value); -#else -//For non-UNIX systems - _log = value; -#endif - + continue; } if (variable == "documentroot") { _wwwroot = value; + continue; } if (variable == "blacklist") { string::size_type pos; - while ((pos = value.find(':', 0)) != string::npos) { + //This is an ugly way to avoid breaking lists + //Lists will work if they worked before, but + //combining the two separators will not. + //The colon way must be removed before protocols + //(http://, https:// can be included in lists). + char separator; + if (value.find(':') != string::npos) separator = ':'; + else separator = ' '; + while (value.size()) { + pos = value.find(separator, 0); _blacklist.push_back(value.substr(0, pos)); - value.erase(0, pos+1); + value.erase(0, pos); + if (value.size()) value.erase(0, value.find_first_not_of(separator)); } - _blacklist.push_back(value); continue; } + if (variable == "whitelist") { string::size_type pos; - while ((pos = value.find(':', 0)) != string::npos) { + //This is an ugly way to avoid breaking lists + //Lists will work if they worked before, but + //combining the two separators will not. + //The colon way must be removed before protocols + //(http://, https:// can be included in lists). + char separator; + if (value.find(':') != string::npos) separator = ':'; + else separator = ' '; + while (value.size()) { + pos = value.find(separator, 0); _whitelist.push_back(value.substr(0, pos)); - value.erase(0, pos+1); + value.erase(0, pos); + if (value.size()) value.erase(0, value.find_first_not_of(separator)); } - _whitelist.push_back(value); continue; } } Index: libbase/rc.h =================================================================== RCS file: /cvsroot/gnash/gnash/libbase/rc.h,v retrieving revision 1.24 retrieving revision 1.25 diff -u -b -r1.24 -r1.25 --- libbase/rc.h 20 Aug 2007 22:59:26 -0000 1.24 +++ libbase/rc.h 23 Aug 2007 09:37:22 -0000 1.25 @@ -96,12 +96,6 @@ bool useLocalHost() const { return _localhost_only; } void useLocalHost(bool value); - static bool extractSetting(bool *var, const char *pattern, std::string &variable, - std::string &value); - - static int extractNumber(int *num, const char *pattern, std::string &variable, - std::string &value); - const std::vector<std::string>& getWhiteList() const { return _whitelist; } const std::vector<std::string>& getBlackList() const { return _blacklist; } @@ -117,7 +111,7 @@ /// Construct only by getDefaultInstance() RcInitFile(); - /// Never destry (TODO: add a destroyDefaultInstance) + /// Never destroy (TODO: add a destroyDefaultInstance) ~RcInitFile(); int _delay; // the timer delay @@ -151,11 +145,17 @@ bool _sound; // whether sound is enable or not bool _plugin_sound; // whether sound is desired for the plugin - bool _extensionsEnabled; // wheter to scan plugin path for extensions + bool _extensionsEnabled; // whether to scan plugin path for extensions bool _startStopped; // whether to start the gui in "stop" mode - static std::string expandPath(std::string& unixpath); + static std::string expandPath(std::string _path); //path string operations + + static bool extractSetting(bool *var, const char *pattern, + std::string &variable, std::string &value); + + static int extractNumber(int *num, const char *pattern, + std::string &variable, std::string &value); }; _______________________________________________ Gnash-commit mailing list Gnash-commit@gnu.org http://lists.gnu.org/mailman/listinfo/gnash-commit