phpMyEdit - Viewing Bug Advanced Details [ Go Back ]
678 core / general block always 2010-05-12 17:33 2010-05-12 17:33
the_max@libero.it PHP 5.2.5 + MySQL 5.0.45  
Windows XP  
normal SP3  
new 5.7.1 (stable)  
v 1.204 2007-09-16 12:57:07 open  
none  
none  
JavaScript regular expression is not working! Wrong JS code cause no data validation.
JavaScript regular expression is not working! Wrong JS code cause no data validation in the function PME_js_form_control.
I have find and fixed PHP lines code (see solution)
The following code produce invalid JS code in HTML page :

$opts['fdd']['Utente'] = array(
'name' => 'Utente',
'help' => 'Nome utente usato per il login (account di accesso)',
'select' => 'T',
'js' => array('required' => true),
'maxlen' => 40,
'sort' => true
);
$opts['fdd']['EMail'] = array(
'name' => 'EMail',
'help' => 'Indirizzo e-mail (nel formato : stringa@nomedominio.estensione)',
'js' => array('regexp' => '.+@.+\\.[a-z]+', 'hint' => 'Inserire un indirizzo email valido!'),
'select' => 'T',
'maxlen' => 40,
'sort' => true
);
// Now important call to phpMyEdit
require_once('../phpMyEdit.class.php');
$myedit = new phpMyEdit($opts);
The Solution is to replace the following code (after modification js required fields and js regexp works OK) :

if (isset($this->fdd[$k]['js']['regexp'])) {
$condition .= (strlen($condition) > 0 ? ' || ' : '');
$condition .= sprintf('!(%s.test('.$this->js['prefix'].'trim(theForm.%s.value)))',
$this->fdd[$k]['js']['regexp'], $this->cgi['prefix']['data'].$this->fds[$k]);
}

With this code :

if (isset($this->fdd[$k]['js']['regexp'])) {
// Build javascript regular expression condition!
// JS line code example : if (!(theForm.PME_data_EMail.value.match(new RegExp(".+@.+\.[a-z]+")))) {

$condition .= (strlen($condition) > 0 ? ' || ' : '');
$condition .= sprintf('!(theForm.%s.value.match(new RegExp("%s")))', $this->cgi['prefix']['data'].$this->fds[$k], $this->fdd[$k]['js']['regexp']);
}

There are no notes attached to this bug.