Author: elias
Date: Wed Oct  8 15:29:50 2008
New Revision: 29964

URL: http://svn.gna.org/viewcvs/wesnoth?rev=29964&view=rev
Log:
Removed scan for python files when uploading campaigns - this only was needed 
before the routing of python scripts through safe.py. Also removed the 
validation mechanism for python scripts - it never was used as far as I know.

Modified:
    trunk/data/tools/wesnoth_addon_manager
    trunk/src/campaign_server/campaign_server.cpp

Modified: trunk/data/tools/wesnoth_addon_manager
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/data/tools/wesnoth_addon_manager?rev=29964&r1=29963&r2=29964&view=diff
==============================================================================
--- trunk/data/tools/wesnoth_addon_manager (original)
+++ trunk/data/tools/wesnoth_addon_manager Wed Oct  8 15:29:50 2008
@@ -64,10 +64,6 @@
         help = "Update all installed add-ons in the given directory. " +
         "This works by comparing the _info.cfg file in each addon directory " +
         "with the version on the server.")
-    optionparser.add_option("-v", "--validate",
-        help = "validate python scripts in an add-on " +
-        "(VALIDATE specifies the name of the add-on, " +
-        "set the password with -P)")
     optionparser.add_option("-V", "--verbose",
         help = "be even more verbose for everything",
         action = "store_true",)

Modified: trunk/src/campaign_server/campaign_server.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/campaign_server/campaign_server.cpp?rev=29964&r1=29963&r2=29964&view=diff
==============================================================================
--- trunk/src/campaign_server/campaign_server.cpp (original)
+++ trunk/src/campaign_server/campaign_server.cpp Wed Oct  8 15:29:50 2008
@@ -216,66 +216,6 @@
                                find_translations(**i, campaign);
                        }
                }
-       }
-
-       // Given an uploaded campaign, rename all .py files to .py.unchecked, 
unless
-       // the contents are the same as a .py file in an existing campaign.
-       // This means, a .py.unchecked file can be approved by simply renaming 
it
-       // on the CS, and it will remain approved as long as it is not changed 
(but
-       // it can be moved/renamed). If the .py file changes, it needs to be 
approved
-       // again.
-       std::string check_python_scripts(config &data, std::string filename)
-       {
-               std::vector<config *> python_scripts = find_scripts(data, 
".py");
-               if (!python_scripts.empty()) {
-                       // Campaign contains python scripts.
-                       config old_campaign;
-                       scoped_istream stream = istream_file(filename);
-                       read_gz(old_campaign, *stream);
-                       std::vector<config *> old_scripts = 
find_scripts(old_campaign, ".py");
-                       std::string script_names = "";
-                       std::vector<config *>::iterator i, j;
-                       // Go through all newly uploaded python scripts.
-                       for (i = python_scripts.begin(); i != 
python_scripts.end(); ++i) {
-                               bool already = false;
-                               // Compare to existing, approved scripts.
-                               for (j = old_scripts.begin(); j != 
old_scripts.end(); ++j) {
-                                       if ((**i)["contents"] != 
(**j)["contents"]) continue;
-                                       already = true;
-                                       break;
-                               }
-                               if (!already) {
-                                       script_names += "\n" + (**i)["name"];
-                                       (**i)["name"] += ".unchecked";
-                               }
-                       }
-                       if (script_names != "")
-                               return "\nScripts awaiting approval:\n" + 
script_names;
-               }
-               return "";
-       }
-
-       // Go through all .py.unchecked files in the given campaign, and rename 
them to
-       // .py. This is the opposite to check_python_scripts(), and while the 
latter is
-       // done on campaign upload, this function is called for the 
validate_scripts
-       // command.
-       std::string validate_all_python_scripts(config &data)
-       {
-               std::vector<config *> python_scripts = find_scripts(data, 
".py.unchecked");
-               if (!python_scripts.empty()) {
-                       // Campaign contains unchecked python scripts.
-                       std::string script_names = "";
-                       std::vector<config *>::iterator i;
-                       // Go through all unchecked python scripts.
-                       for (i = python_scripts.begin(); i != 
python_scripts.end(); ++i) {
-                               std::string name = (**i)["name"];
-                               name.resize(name.length() - 10);
-                               (**i)["name"] = name;
-                               script_names += "\n" + name;
-                       }
-                       return script_names;
-               }
-               return "";
        }
 
        // Add a file COPYING.txt with the GPL to an uploaded campaign.
@@ -589,11 +529,6 @@
                                                        
(*campaign).clear_children("translation");
                                                        
find_translations(*data, *campaign);
 
-                                                       // Campaigns which have 
python="allowed" are not checked
-                                                       if 
((*campaign)["python"] != "allowed") {
-                                                               message += 
check_python_scripts(*data, filename);
-                                                       }
-
                                                        add_license(*data);
 
                                                        {
@@ -653,40 +588,6 @@
                                                        scoped_ostream cfgfile 
= ostream_file(file_);
                                                        write(*cfgfile, cfg_);
                                                        
network::send_data(construct_message("Passphrase changed."), sock, gzipped);
-                                               }
-                                       } else if(const config* cvalidate = 
data.child("validate_scripts")) {
-                                               config* campaign = 
campaigns().find_child("campaign","name",(*cvalidate)["name"]);
-                                               if(campaign == NULL) {
-                                                       
network::send_data(construct_error(
-                                                                               
"No add-on with that name exists."), sock, gzipped);
-                                               } else 
if(campaigns()["master_password"] == "") {
-                                                       
network::send_data(construct_error(
-                                                                               
"Sever does not allow scripts."), sock, gzipped);
-                                               } else if 
(campaigns()["master_password"] != (*cvalidate)["master_password"]) {
-                                                       
network::send_data(construct_error(
-                                                                               
"Password was incorrect."), sock, gzipped);
-                                               } else {
-                                                       // Read the campaign 
from disk.
-                                                       config campaign_file;
-                                                       scoped_istream stream = 
istream_file((*campaign)["filename"]);
-                                                       read_gz(campaign_file, 
*stream);
-                                                       std::string scripts = 
validate_all_python_scripts(campaign_file);
-                                                       if (!scripts.empty()) {
-                                                               // Write the 
campaign with changed filenames back to disk
-                                                               {
-                                                                       
scoped_ostream ostream = ostream_file((*campaign)["filename"]);
-                                                                       
config_writer writer(*ostream, true, "",compress_level_);
-                                                                       
writer.write(campaign_file);
-                                                               }
-//                                                             
write_compressed(*ostream, campaign_file);
-                                                               
(*campaign)["size"] = lexical_cast<std::string>(
-                                                                               
file_size((*campaign)["filename"]));
-
-                                                               
network::send_data(construct_message("The following scripts have been 
validated: " +
-                                                                               
        scripts), sock, gzipped);
-                                                       } else {
-                                                               
network::send_data(construct_message("No unchecked scripts found!"), sock, 
gzipped);
-                                                       }
                                                }
                                        }
                                }


_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits

Reply via email to