Skip to content

Commit

Permalink
Fixed issue #9406: Unable to save survey
Browse files Browse the repository at this point in the history
  • Loading branch information
c-schmitz committed Dec 30, 2014
1 parent 77357a0 commit 6b9585d
Showing 1 changed file with 1 addition and 110 deletions.
111 changes: 1 addition & 110 deletions application/helpers/common_helper.php
Expand Up @@ -1684,116 +1684,7 @@ function validateEmailAddress($sEmailAddress){
{
return true;
}

$bits = array(
'local' => isset($m[1]) ? $m[1] : '',
'local-atom' => isset($m[2]) ? $m[2] : '',
'local-quoted' => isset($m[3]) ? $m[3] : '',
'local-obs' => isset($m[4]) ? $m[4] : '',
'domain' => isset($m[5]) ? $m[5] : '',
'domain-atom' => isset($m[6]) ? $m[6] : '',
'domain-literal' => isset($m[7]) ? $m[7] : '',
'domain-obs' => isset($m[8]) ? $m[8] : '',
);



$bits['local'] = stripComments($comment, $bits['local']);
$bits['domain'] = stripComments($comment, $bits['domain']);




if (strlen($bits['local']) > 64) return FALSE;
if (strlen($bits['domain']) > 255) return FALSE;



if (strlen($bits['domain-literal'])){

$Snum = "(\d{1,3})";
$IPv4_address_literal = "$Snum\.$Snum\.$Snum\.$Snum";

$IPv6_hex = "(?:[0-9a-fA-F]{1,4})";

$IPv6_full = "IPv6\:$IPv6_hex(:?\:$IPv6_hex){7}";

$IPv6_comp_part = "(?:$IPv6_hex(?:\:$IPv6_hex){0,5})?";
$IPv6_comp = "IPv6\:($IPv6_comp_part\:\:$IPv6_comp_part)";

$IPv6v4_full = "IPv6\:$IPv6_hex(?:\:$IPv6_hex){5}\:$IPv4_address_literal";

$IPv6v4_comp_part = "$IPv6_hex(?:\:$IPv6_hex){0,3}";
$IPv6v4_comp = "IPv6\:((?:$IPv6v4_comp_part)?\:\:(?:$IPv6v4_comp_part\:)?)$IPv4_address_literal";



if (preg_match("!^\[$IPv4_address_literal\]$!", $bits['domain'], $m)){

if (intval($m[1]) > 255) return FALSE;
if (intval($m[2]) > 255) return FALSE;
if (intval($m[3]) > 255) return FALSE;
if (intval($m[4]) > 255) return FALSE;

}else{


while (1){

if (preg_match("!^\[$IPv6_full\]$!", $bits['domain'])){
break;
}

if (preg_match("!^\[$IPv6_comp\]$!", $bits['domain'], $m)){
list($a, $b) = explode('::', $m[1]);
$folded = (strlen($a) && strlen($b)) ? "$a:$b" : "$a$b";
$groups = explode(':', $folded);
if (count($groups) > 6) return FALSE;
break;
}

if (preg_match("!^\[$IPv6v4_full\]$!", $bits['domain'], $m)){

if (intval($m[1]) > 255) return FALSE;
if (intval($m[2]) > 255) return FALSE;
if (intval($m[3]) > 255) return FALSE;
if (intval($m[4]) > 255) return FALSE;
break;
}

if (preg_match("!^\[$IPv6v4_comp\]$!", $bits['domain'], $m)){
list($a, $b) = explode('::', $m[1]);
$b = substr($b, 0, -1); # remove the trailing colon before the IPv4 address
$folded = (strlen($a) && strlen($b)) ? "$a:$b" : "$a$b";
$groups = explode(':', $folded);
if (count($groups) > 4) return FALSE;
break;
}

return FALSE;
}
}
}else{


$labels = explode('.', $bits['domain']);


if (count($labels) == 1) return FALSE;


foreach ($labels as $label){

if (strlen($label) > 63) return FALSE;
if (substr($label, 0, 1) == '-') return FALSE;
if (substr($label, -1) == '-') return FALSE;
}

if (preg_match('!^[0-9]+$!', array_pop($labels))) return FALSE;
}


return TRUE;
return false;
}

/**
Expand Down

0 comments on commit 6b9585d

Please sign in to comment.