From 0ef287b2b7d80db62d4a2bf3ef816bc0cca43ac7 Mon Sep 17 00:00:00 2001 From: h-alstad <> Date: Tue, 2 Mar 2010 21:27:01 +0100 Subject: [PATCH] Fixed bug #522241, convert special chars to html entities --- inside/Article.php | 48 +++++++++++++++++++++++----------------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/inside/Article.php b/inside/Article.php index 9632647..cd0dce3 100644 --- a/inside/Article.php +++ b/inside/Article.php @@ -19,7 +19,7 @@ class Article { public $updated_by; public $updated_at; public $expires; - + public $conn; @@ -30,7 +30,7 @@ class Article { if ($id == NULL){//New article if ($data == NULL){ - error('Article: No data supplied.'); + error('Article: No data supplied.'); }else { $this->author = getCurrentUserName(); $this->updated_by = getCurrentUserName(); @@ -40,25 +40,25 @@ class Article { }else {//ID set, existing article if ($data != NULL){//Update existing article $this->updated_by = getCurrentUserName(); - + //primary attachment if($_FILES['attachment1']['error'] != 4){ $temp_name = new_file($_FILES['attachment1'], 'nyheter'); rename_file($temp_name, $this->id, 'nyheter'); $this->attachment1 = $this->id.substr($temp_name, -4); }else { - $this->attachment1 = 0; + $this->attachment1 = 0; } - + //secondary attachment if($_FILES['attachment2']['error'] != 4){ $temp_name = new_file($_FILES['attachment2'], 'nyheter'); rename_file($temp_name, $this->id.'_2', 'nyheter'); $this->attachment2 = $this->id.'_2'.substr($temp_name, -4); }else { - $this->attachment2 = 0; + $this->attachment2 = 0; } - + }else {//Retrieve data from backend for display or other actions $data = $this->_retrieveData(); $this->date = $data['date']; @@ -70,8 +70,8 @@ class Article { } } //Common initializations - $this->title = $data['title']; - $this->intro = stripcslashes($data['intro']); + $this->title = htmlspecialchars(stripslashes($data['title'])); + $this->intro = stripcslashes($data['intro']); $this->text = stripcslashes($data['text']); $this->caption1 = $data['caption1']; $this->caption2 = $data['caption2']; @@ -103,16 +103,16 @@ class Article { rename_file($temp_name, $this->id, 'nyheter'); $this->attachment1 = $this->id.substr($temp_name, -4); }else { - $this->attachment1 = 0; + $this->attachment1 = 0; } - + //secondary attachment if($_FILES['attachment2']['error'] != 4){ $temp_name = new_file($_FILES['attachment2'], 'nyheter'); rename_file($temp_name, $this->id.'_2', 'nyheter'); $this->attachment2 = $this->id.'_2'.substr($temp_name, -4); }else { - $this->attachment2 = 0; + $this->attachment2 = 0; } $this->_storeFilenames(); @@ -122,7 +122,7 @@ class Article { error("New article: " . $result->toString()); } }else { - $sql = sprintf("UPDATE nyhet SET + $sql = sprintf("UPDATE nyhet SET tittel = %s, ingress = %s, tekst = %s, @@ -131,7 +131,7 @@ class Article { caption2 = %s, sistEndretAv = %s, sistEndret = NOW() - WHERE + WHERE id = %s", $this->conn->quoteSmart($this->title), $this->conn->quoteSmart($this->intro), @@ -181,8 +181,8 @@ class Article { public function delete($id){ $conn = db_connect(); - $sql = "DELETE FROM nyhet - WHERE id = $id + $sql = "DELETE FROM nyhet + WHERE id = $id LIMIT 1"; $result = $conn->query($sql); if (DB::isError($result) != true){ @@ -213,35 +213,35 @@ class Article { print(''); } print(''); - + //$text = str_replace("[img2]", $this->_text_insert_attachment($this->attachment2, $this->caption2), $this->text); $text = str_replace('[img2]', '', $this->text); ?>
date); ?>
+date); ?>
intro); ?>