Changeset 1664

Show
Ignore:
Timestamp:
06/30/08 21:32:48 (2 months ago)
Author:
mikey
Message:

fix bug with htmlentities() and charsets, corrected to htmlspecialchars() which should be used anyway

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/main/php/net/stubbles/websites/memphis/stubMemphisProcessor.php

    r1577 r1664  
    236236    { 
    237237        $this->template->addGlobalVar('UCUO_FRAME', $this->context['frameId']); 
    238         $this->template->addGlobalVar('PAGE_TITLE', htmlentities($this->context['page']->getProperty('title'))); 
     238        $title = $this->context['page']->getProperty('title'); 
     239        $this->template->addGlobalVar('PAGE_TITLE', htmlspecialchars($title, ENT_COMPAT, mb_detect_encoding($title, 'UTF-8, ISO-8859-1'))); 
    239240        $this->template->addGlobalVar('PAGE_NAME', $this->context['pageName']); 
    240241        $this->template->addGlobalVar('VARIANT', $this->session->getValue('net.stubbles.websites.variantmanager.variant.name', '')); 
     
    251252        // add meta information to the page 
    252253        foreach ($this->config->getMetaTags() as $key => $value) { 
    253             $this->template->addVar('frame', 'META_' . $key, htmlentities($value)); 
     254            $this->template->addVar('frame', 'META_' . $key, htmlspecialchars($value, ENT_COMPAT, mb_detect_encoding($title, 'UTF-8, ISO-8859-1'))); 
    254255        } 
    255256 
  • trunk/src/test/php/net/stubbles/websites/memphis/stubMemphisProcessorTestCase.php

    r1511 r1664  
    368368    public function setTemplateVars1() 
    369369    { 
    370         $this->mockPage->expects($this->once())->method('getProperty')->will($this->returnValue('bar')); 
     370        $this->mockPage->expects($this->once())->method('getProperty')->will($this->returnValue(utf8_encode('bör'))); 
    371371        $this->mockMemphisConfig->expects($this->any()) 
    372372                                ->method('getMetaTags') 
    373                                 ->will($this->returnValue(array('description' => 'This is a description.'
     373                                ->will($this->returnValue(array('description' => utf8_encode('This is a description containing an Ümlaut.')
    374374                                                                'keywords'    => 'keyword1, keyword2' 
    375375                                                          ))); 
     
    380380        $this->memphisProcessor->callSetTemplateVars(); 
    381381        $this->assertEquals(array('UCUO_FRAME'    => 'frame', 
    382                                   'PAGE_TITLE'    => 'bar'
     382                                  'PAGE_TITLE'    => utf8_encode('bör')
    383383                                  'PAGE_NAME'     => 'index', 
    384384                                  'VARIANT'       => null, 
     
    392392                            $dummyTemplate->getGlobalVars() 
    393393        ); 
    394         $this->assertEquals(array('frame' => array('META_description' => 'This is a description.'
     394        $this->assertEquals(array('frame' => array('META_description' => utf8_encode('This is a description containing an Ümlaut.')
    395395                                                   'META_keywords'    => 'keyword1, keyword2' 
    396396                                             ) 
     
    407407    public function setTemplateVars() 
    408408    { 
    409         $this->mockPage->expects($this->once())->method('getProperty')->will($this->returnValue('<bar>')); 
     409        $this->mockPage->expects($this->once())->method('getProperty')->will($this->returnValue('<bür>')); 
    410410        $this->mockMemphisConfig->expects($this->any()) 
    411411                                ->method('getMetaTags') 
     
    419419        $this->memphisProcessor->callSetTemplateVars(); 
    420420        $this->assertEquals(array('UCUO_FRAME'    => 'frame', 
    421                                   'PAGE_TITLE'    => '&lt;bar&gt;', 
     421                                  'PAGE_TITLE'    => '&lt;bür&gt;', 
    422422                                  'PAGE_NAME'     => 'index', 
    423423                                  'VARIANT'       => 'variant',