private function validate() { if (empty($this->raw) or '' == trim($this->raw)) { $this->valid = true; return true; } // CAS keyval may not contain @ or $. if (strpos($this->raw, '@') !== false || strpos($this->raw, '$') !== false) { $this->errors = stack_string('illegalcaschars'); $this->valid = false; return false; } // Subtle one: must protect things inside strings before we explode. $str = $this->raw; $strings = stack_utils::all_substring_strings($str); foreach ($strings as $key => $string) { $str = str_replace('"' . $string . '"', '[STR:' . $key . ']', $str); } $str = str_replace("\n", ';', $str); $str = stack_utils::remove_comments($str); $str = str_replace(';', "\n", $str); $kvarray = explode("\n", $str); foreach ($strings as $key => $string) { foreach ($kvarray as $kkey => $kstr) { $kvarray[$kkey] = str_replace('[STR:' . $key . ']', '"' . $string . '"', $kstr); } } // 23/4/12 - significant changes to the way keyvals are interpreted. Use Maxima assignmentsm i.e. x:2. $errors = ''; $valid = true; $vars = array(); foreach ($kvarray as $kvs) { $kvs = trim($kvs); if ('' != $kvs) { $cs = new stack_cas_casstring($kvs); $cs->get_valid($this->security, $this->syntax, $this->insertstars); $vars[] = $cs; } } $this->session->add_vars($vars); $this->valid = $this->session->get_valid(); $this->errors = $this->session->get_errors(); }
private function strings_remove($cmd) { $strings = stack_utils::all_substring_strings($cmd); foreach ($strings as $key => $string) { $cmd = str_replace('"' . $string . '"', '[STR:' . $key . ']', $cmd); } return array($cmd, $strings); }