From 52ae5aef521fa7d800e09206342eb9ac17043cd8 Mon Sep 17 00:00:00 2001 From: wei <> Date: Fri, 13 Jan 2006 12:57:54 +0000 Subject: --- framework/3rdParty/readme.html | 11 +++++-- framework/Web/UI/WebControls/TTextBox.php | 29 ++++++++++++++--- tests/FunctionalTests/protected/application.xml | 1 - tests/FunctionalTests/protected/pages/Home.page | 35 ++------------------- .../protected/pages/I18N/BasicI18N.page | 36 ++-------------------- .../pages/Validation/RequiredFieldValidator.page | 7 +++-- .../pages/Validation/RequiredFieldValidator.php | 5 +-- 7 files changed, 46 insertions(+), 78 deletions(-) diff --git a/framework/3rdParty/readme.html b/framework/3rdParty/readme.html index e48eba45..b84425f2 100644 --- a/framework/3rdParty/readme.html +++ b/framework/3rdParty/readme.html @@ -19,8 +19,8 @@ projects. - geshi - GeSHi - Generic Syntax Highlighter (v1.0.7.5) + geshi + GeSHi - Generic Syntax Highlighter (v1.0.7.5) GNU System.Web.UI.WebControls.TTextHighlighter Many syntax files are stripped off to reduce the size of PRADO release. @@ -28,6 +28,13 @@ projects. recognize PHP5-specific keywords. Modified geshi.php so that it conforms to strict PHP5 syntax. + + SafeHtml + SafeHTML (v1.3.7) + BSD License (3 Clause) + System.Web.UI.WebControls.TSafeHtml + TSafeHtml removes malicious javascript code from its rendered output. +

diff --git a/framework/Web/UI/WebControls/TTextBox.php b/framework/Web/UI/WebControls/TTextBox.php index e37b98b8..dae0ccf8 100644 --- a/framework/Web/UI/WebControls/TTextBox.php +++ b/framework/Web/UI/WebControls/TTextBox.php @@ -10,6 +10,8 @@ * @package System.Web.UI.WebControls */ +Prado::using('System.3rdParty.SafeHtml.TSafeHtmlParser'); + /** * TTextBox class * @@ -55,6 +57,8 @@ class TTextBox extends TWebControl implements IPostBackDataHandler, IValidatable */ private static $_autoCompleteTypes=array('BusinessCity','BusinessCountryRegion','BusinessFax','BusinessPhone','BusinessState','BusinessStreetAddress','BusinessUrl','BusinessZipCode','Cellular','Company','Department','Disabled','DisplayName','Email','FirstName','Gender','HomeCity','HomeCountryRegion','HomeFax','Homepage','HomePhone','HomeState','HomeStreetAddress','HomeZipCode','JobTitle','LastName','MiddleName','None','Notes','Office','Pager','Search'); + protected $_safeContent; + /** * @return string tag name of the textbox */ @@ -90,7 +94,7 @@ class TTextBox extends TWebControl implements IPostBackDataHandler, IValidatable if($textMode==='SingleLine') { $writer->addAttribute('type','text'); - if(($text=$this->getText())!=='') + if(($text=$this->getRawText())!=='') $writer->addAttribute('value',$text); if(($act=$this->getAutoCompleteType())!=='None') { @@ -169,7 +173,7 @@ class TTextBox extends TWebControl implements IPostBackDataHandler, IValidatable public function loadPostData($key,$values) { $value=$values[$key]; - if(!$this->getReadOnly() && $this->getText()!==$value) + if(!$this->getReadOnly() && $this->getRawText()!==$value) { $this->setText($value); return true; @@ -226,7 +230,7 @@ class TTextBox extends TWebControl implements IPostBackDataHandler, IValidatable protected function renderContents($writer) { if($this->getTextMode()==='MultiLine') - $writer->write(THttpUtility::htmlEncode($this->getText())); + $writer->write(THttpUtility::htmlEncode($this->getRawText())); } /** @@ -358,13 +362,27 @@ class TTextBox extends TWebControl implements IPostBackDataHandler, IValidatable } /** - * @return string the text content of the TTextBox control. + * @return string the unmodified text content of the TTextBox control. */ - public function getText() + public function getRawText() { return $this->getViewState('Text',''); } + /** + * @return string safe text content. + */ + public function getText() + { + $text = $this->getRawText(); + if(is_null($this->_safeContent)) + { + $renderer = new TSafeHtmlParser(); + $this->_safeContent = $renderer->parse($text); + } + return $this->_safeContent; + } + /** * Sets the text content of the TTextBox control. * @param string the text content @@ -372,6 +390,7 @@ class TTextBox extends TWebControl implements IPostBackDataHandler, IValidatable public function setText($value) { $this->setViewState('Text',$value,''); + $this->_safeContent = null; } /** diff --git a/tests/FunctionalTests/protected/application.xml b/tests/FunctionalTests/protected/application.xml index ca946653..53e73457 100644 --- a/tests/FunctionalTests/protected/application.xml +++ b/tests/FunctionalTests/protected/application.xml @@ -13,7 +13,6 @@ - \ No newline at end of file diff --git a/tests/FunctionalTests/protected/pages/Home.page b/tests/FunctionalTests/protected/pages/Home.page index 606a17ac..9a49e3a2 100644 --- a/tests/FunctionalTests/protected/pages/Home.page +++ b/tests/FunctionalTests/protected/pages/Home.page @@ -1,34 +1,3 @@ - - - - - - Prado Functional Tests - - - - - +

Prado Functional Tests

- -
- - Validate XHTML 1.0 - -
- - \ No newline at end of file +
\ No newline at end of file diff --git a/tests/FunctionalTests/protected/pages/I18N/BasicI18N.page b/tests/FunctionalTests/protected/pages/I18N/BasicI18N.page index e09c2161..f4ef35d2 100644 --- a/tests/FunctionalTests/protected/pages/I18N/BasicI18N.page +++ b/tests/FunctionalTests/protected/pages/I18N/BasicI18N.page @@ -1,28 +1,5 @@ -<%@ Application.Globalization.Culture="zh_CN" %> - - - - - - Basic I18N Test - - - - +<%@ Title="Basic I18N Test" %> +

Basic I18N Test

Hello {name} @@ -51,11 +28,4 @@ [0] None |[1] One thing. |[2,Inf) Many things. - - - - \ No newline at end of file +
\ No newline at end of file diff --git a/tests/FunctionalTests/protected/pages/Validation/RequiredFieldValidator.page b/tests/FunctionalTests/protected/pages/Validation/RequiredFieldValidator.page index 56ef07bd..e6b67c8d 100644 --- a/tests/FunctionalTests/protected/pages/Validation/RequiredFieldValidator.page +++ b/tests/FunctionalTests/protected/pages/Validation/RequiredFieldValidator.page @@ -1,13 +1,16 @@ +<%@ Title="Basic TRequiredFieldValidator" %> +

Basic TRequiredFieldValidator Test1

-
\ No newline at end of file + +
\ No newline at end of file diff --git a/tests/FunctionalTests/protected/pages/Validation/RequiredFieldValidator.php b/tests/FunctionalTests/protected/pages/Validation/RequiredFieldValidator.php index 995b3df0..ff24b93a 100644 --- a/tests/FunctionalTests/protected/pages/Validation/RequiredFieldValidator.php +++ b/tests/FunctionalTests/protected/pages/Validation/RequiredFieldValidator.php @@ -2,9 +2,10 @@ class RequiredFieldValidator extends TPage { - function onLoad($param) + protected function onLoad($param) { - Prado::log("Hello", TLogger::WARNING); + if(!$this->IsPostBack) + $this->dataBind(); } } -- cgit v1.2.3