mirror of
https://github.com/tuxis-ie/nsedit.git
synced 2025-04-20 20:13:40 +03:00
Reject non-ASCII-chars and escape quotes in TXT-records
This commit is contained in:
parent
57aab9ef2e
commit
1abfadf28c
1 changed files with 18 additions and 0 deletions
|
@ -45,6 +45,16 @@ function _create_record($name, $records, $input, $zoneurl) {
|
||||||
global $defaults;
|
global $defaults;
|
||||||
|
|
||||||
$content = ($input['type'] == "TXT") ? '"'.$input['content'].'"' : $input['content'];
|
$content = ($input['type'] == "TXT") ? '"'.$input['content'].'"' : $input['content'];
|
||||||
|
|
||||||
|
if (is_ascii($content) === FALSE or is_ascii($input['name']) === FALSE) {
|
||||||
|
_jtable_respond(null, 'error', "Please only use ASCII-characters in your fields");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (preg_match('/^TXT$/', $input['type'])) {
|
||||||
|
$content = addslashes($input['content']);
|
||||||
|
$content = '"'.$content.'"';
|
||||||
|
}
|
||||||
|
|
||||||
array_push($records, array(
|
array_push($records, array(
|
||||||
'disabled' => false,
|
'disabled' => false,
|
||||||
'type' => $input['type'],
|
'type' => $input['type'],
|
||||||
|
@ -66,6 +76,14 @@ function _create_record($name, $records, $input, $zoneurl) {
|
||||||
return $records;
|
return $records;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* This function is taken from:
|
||||||
|
http://pageconfig.com/post/how-to-validate-ascii-text-in-php and got fixed by
|
||||||
|
#powerdns */
|
||||||
|
|
||||||
|
function is_ascii( $string = '' ) {
|
||||||
|
return ( bool ) ! preg_match( '/[\\x00-\\x08\\x0b\\x0c\\x0e-\\x1f\\x80-\\xff]/' , $string );
|
||||||
|
}
|
||||||
|
|
||||||
function getrecords_by_name_type($zoneurl, $name, $type) {
|
function getrecords_by_name_type($zoneurl, $name, $type) {
|
||||||
$zone = json_decode(_do_curl($zoneurl), 1);
|
$zone = json_decode(_do_curl($zoneurl), 1);
|
||||||
$records = array();
|
$records = array();
|
||||||
|
|
Loading…
Add table
Reference in a new issue