diff --git a/controller/checklist/UtilForChecklist.php b/controller/checklist/UtilForChecklist.php index da929fb..1fbce37 100644 --- a/controller/checklist/UtilForChecklist.php +++ b/controller/checklist/UtilForChecklist.php @@ -24,4 +24,16 @@ public static function getPercentIntoCheckboxes(string $body): int return (int)floor($checked / $total * 100); } + /** + * adjust content + * + * @param string $content + * @return string + */ + public static function adjustContent(string $content): string + { + $content = str_replace("'", "\'", $content); + return $content; + } + } diff --git a/controller/checklist/add_item.php b/controller/checklist/add_item.php index 590af30..ff33242 100644 --- a/controller/checklist/add_item.php +++ b/controller/checklist/add_item.php @@ -25,6 +25,9 @@ // set percent into content $percent = UtilForChecklist::getPercentIntoCheckboxes($this->post->content); + // adjust content + $content = UtilForChecklist::adjustContent($this->post->content); + // set output $output = Controller\Main::add($this, (object)[ 'table' => 'checklist', @@ -32,7 +35,7 @@ 'data' => (object)[ 'srl' => null, 'user_srl' => (int)$token->data->user_srl, - 'content' => $this->post->content, + 'content' => $content, 'percent' => $percent, 'regdate' => isset($this->post->regdate) ? $this->post->regdate : date('Y-m-d H:i:s'), ], diff --git a/controller/checklist/edit_item.php b/controller/checklist/edit_item.php index 63c6637..c246154 100644 --- a/controller/checklist/edit_item.php +++ b/controller/checklist/edit_item.php @@ -35,12 +35,15 @@ 'srl' => $srl, ]); + // adjust content + $content = UtilForChecklist::adjustContent($this->post->content); + // set output $output = Controller\Main::edit($this, (object)[ 'table' => 'checklist', 'srl' => $srl, 'data' => [ - "content='{$this->post->content}'", + "content='{$content}'", "percent={$percent}", ], ]);