Ticket #9464: patch2.diff

File patch2.diff, 1018 bytes (added by anonymous, 9 years ago)

Function to replace <,>,& with XML escape sequences.

  • classes/FeedItem.php

    diff --git a/classes/FeedItem.php b/classes/FeedItem.php
    index 9350d65..954e613 100644
    a b  
    1212        private $elements = array();    //Collection of feed elements
    1313        private $version;
    1414
     15
    1516/**
    1617 * Constructor
    1718 *
     
    2223        }
    2324
    2425/**
     26 * Make a string XML safe
     27*/
     28       private function xml_str($strin) {
     29            $strout = str_replace("&","&amp;",$strin);
     30            $strout = str_replace("<","&lt;",$strout);
     31            $strout = str_replace(">","&gt;",$strout);
     32            return $strout;
     33        }
     34
     35
     36/**
    2537 * Add an element to elements array
    2638 *
    2739 * @access   public
     
    3244 */
    3345        public function addElement($elementName, $content, $attributes = null) {
    3446                $this->elements[$elementName]['name']       = $elementName;
    35                 $this->elements[$elementName]['content']    = $content;
     47                $this->elements[$elementName]['content']    = $this->xml_str($content);
    3648                $this->elements[$elementName]['attributes'] = $attributes;
    3749        }
    3850