Skip to content

Commit 76747e7

Browse files
committed
web/common: escape validate_input regex before sending to js
1 parent dd56721 commit 76747e7

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

web/common/forms.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ function form_generate_input_textarea($title,$tip,$id,$opt,$val,$mlen=null,$re=n
290290
else
291291
$maxlen = "";
292292

293-
$validate=" opt='".$opt."' oninput='auto_grow(this);validate_input(\"".$id."\", \"".$id."_ok\",".($re?"\"".$re."\"":"null").",".$validation.",\"".$json_format."\")'";
293+
$validate=" opt='".$opt."' oninput='auto_grow(this);validate_input(\"".$id."\", \"".$id."_ok\",".($re?"\"".preg_quote($re, '/')."\"":"null").",".$validation.",\"".$json_format."\")'";
294294
$pixelNo = substr_count($val, "\n") * 16 + 35;
295295

296296

@@ -324,7 +324,7 @@ function form_generate_input_text($title,$tip,$id,$opt,$val,$mlen,$re, $validati
324324
else
325325
$value = "";
326326

327-
$validate=" opt='".$opt."' oninput='validate_input(\"".$id."\", \"".$id."_ok\",".($re?"\"".$re."\"":"null").",".($validation?$validation:"null").",\"".$format."\")'";
327+
$validate=" opt='".$opt."' oninput='validate_input(\"".$id."\", \"".$id."_ok\",".($re?"\"".preg_quote($re, '/')."\"":"null").",".($validation?$validation:"null").",\"".$format."\")'";
328328

329329
print("
330330
<tr>

web/common/tools/tviewer/template/tviewer.add.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
<?php if (!isset($value['validation_regex']))
4848
$regex = "null";
4949
else
50-
$regex = '"'.$value['validation_regex'].'"';
50+
$regex = '"'.preg_quote($value['validation_regex'], '/').'"';
5151
$opt = isset($value['is_optional'])?$value['is_optional']:"y";
5252
$validate=" opt='".$opt."' oninput='validate_input(\"".$key."\", \"".$key."_ok\",".$regex.")'";
5353
?>

web/common/tools/tviewer/template/tviewer.edit.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
<?php if (!isset($value['validation_regex']))
6161
$regex = "null";
6262
else
63-
$regex = '"'.$value['validation_regex'].'"';
63+
$regex = '"'.preg_quote($value['validation_regex'], '/').'"';
6464
$opt = isset($value['is_optional'])?$value['is_optional']:"y";
6565
$validate=" opt='".$opt."' valid='ok' oninput='validate_input(\"".$key."\", \"".$key."_ok\",".$regex.")'";
6666
?>

0 commit comments

Comments
 (0)