Skip to content

Commit a51dcb6

Browse files
committed
fix check string utf-8 encoding
1 parent 2792177 commit a51dcb6

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

laravel/app/Http/Controllers/Bus/ToolController.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,17 @@ public function hexToString(Request $request)
4343
{
4444
$hex = strtoupper($request->input('input'));
4545
$hex = str_replace('\\X', '', $hex);
46+
if (!preg_match("/^[A-Fa-f0-9]+$/", $hex)) {
47+
return $this->out(1006);
48+
}
4649
$str = "";
4750
for ($i = 0; $i < strlen($hex) - 1; $i += 2) {
4851
$str .= chr(hexdec($hex[$i].$hex[$i + 1]));
4952
}
50-
return $this->out(200, ['output' => $str]);
53+
if (preg_match('~[\x{4e00}-\x{9fa5}]+~u', $str, $tmp)) {
54+
return $this->out(200, ['output' => (string)$str]);
55+
}
56+
return $this->out(4009);
5157
}
58+
5259
}

0 commit comments

Comments
 (0)