Skip to content
  • Leigh B. Stoller's avatar
    First try at solving the problem of validating user input for the · 8dbead16
    Leigh B. Stoller authored
    zillions of DB fields that we have to set. My solution was to add a
    meta table that describes what is a legal value for each table/slot
    for which we take from user input. The table looks like this right
    now, but is likely to adapt as we get more experience with this
    approach (or it might get tossed if it turns out to be a pain in the
    ass!).
    
    	CREATE TABLE table_regex (
    	  table_name varchar(64) NOT NULL default '',
    	  column_name varchar(64) NOT NULL default '',
    	  column_type enum('text','int','float') default NULL,
    	  check_type enum('regex','function','redirect') default NULL,
    	  check tinytext NOT NULL,
    	  min int(11) NOT NULL default '0',
    	  max int(11) NOT NULL default '0',
    	  comment tinytext,
    	  UNIQUE KEY table_name (table_name,column_name)
    	) TYPE=MyISAM;
    
    Entries in this table look like this:
    
    	('virt_nodes','vname','text','regex','^[-\\w]+$',1,32,NULL);
    
    Which says that the vname slot of the virt_nodes table (which we trust the
    u...
    8dbead16