summaryrefslogtreecommitdiff
path: root/framework/Web
diff options
context:
space:
mode:
authorxue <>2005-12-25 03:26:35 +0000
committerxue <>2005-12-25 03:26:35 +0000
commit47562d9863c63a70c03fabc17f799fc702472ee3 (patch)
tree2bcb2eb1fa0bc2d7ee93cabf63a6146ef47cbf3f /framework/Web
parent14b7b01302f41051e9c86acab252209a95bf89f8 (diff)
Fixed HTML encoding problem.
Diffstat (limited to 'framework/Web')
-rw-r--r--framework/Web/THttpRequest.php8
-rw-r--r--framework/Web/UI/THtmlWriter.php46
-rw-r--r--framework/Web/UI/TTemplateManager.php23
3 files changed, 20 insertions, 57 deletions
diff --git a/framework/Web/THttpRequest.php b/framework/Web/THttpRequest.php
index d42035df..a6fcdf55 100644
--- a/framework/Web/THttpRequest.php
+++ b/framework/Web/THttpRequest.php
@@ -335,21 +335,23 @@ class THttpRequest extends TModule
* @param string service ID
* @param string service parameter
* @param array GET parameters, null if not needed
+ * @param boolean whether to encode the ampersand in URL, defaults to false.
* @return string URL
*/
- public function constructUrl($serviceID,$serviceParam,$getItems=null)
+ public function constructUrl($serviceID,$serviceParam,$getItems=null,$encodeAmpersand=false)
{
$url=$this->getApplicationPath();
$url.='?'.$serviceID.'=';
if(!empty($serviceParam))
$url.=$serviceParam;
+ $amp=$encodeAmpersand?'&amp;':'&';
if(is_array($getItems) || $getItems instanceof Traversable)
{
foreach($getItems as $name=>$value)
- $url.='&amp;'.urlencode($name).'='.urlencode($value);
+ $url.=$amp.urlencode($name).'='.urlencode($value);
}
if(defined('SID') && SID != '')
- $url.='&amp;'.SID;
+ $url.=$amp.SID;
return $url;
}
diff --git a/framework/Web/UI/THtmlWriter.php b/framework/Web/UI/THtmlWriter.php
index 2b2bbd4f..d9c0732b 100644
--- a/framework/Web/UI/THtmlWriter.php
+++ b/framework/Web/UI/THtmlWriter.php
@@ -113,61 +113,22 @@ class THtmlWriter extends TComponent implements ITextWriter
private static $_attrEncode=array(
'abbr'=>true,
'accesskey'=>true,
- 'align'=>false,
'alt'=>true,
- 'autocomplete'=>false,
'axis'=>true,
'background'=>true,
- 'bgcolor'=>false,
- 'border'=>false,
- 'bordercolor'=>false,
- 'cellpadding'=>false,
- 'cellspacing'=>false,
- 'checked'=>false,
'class'=>true,
- 'cols'=>false,
- 'colspan'=>false,
'content'=>true,
- 'coords'=>false,
- 'dir'=>false,
- 'disabled'=>false,
- 'for'=>false,
'headers'=>true,
- 'height'=>false,
'href'=>true,
- 'id'=>false,
'longdesc'=>true,
- 'maxlength'=>false,
- 'multiple'=>false,
- 'name'=>false,
- 'nowrap'=>false,
'onclick'=>true,
'onchange'=>true,
- 'readonly'=>false,
- 'rel'=>false,
- 'rows'=>false,
- 'rowspan'=>false,
- 'rules'=>false,
- 'scope'=>false,
- 'selected'=>false,
- 'shape'=>false,
- 'size'=>false,
'src'=>true,
- 'style'=>false,
- 'tabindex'=>false,
- 'target'=>false,
'title'=>true,
- 'type'=>false,
- 'usemap'=>false,
- 'valign'=>false,
- 'value'=>true,
- 'vcard_name'=>false,
- 'width'=>false,
- 'wrap'=>false
+ 'value'=>true
);
private static $_styleEncode=array(
'background-image'=>true,
- 'font-family'=>false,
'list-style-image'=>true
);
private $_attributes=array();
@@ -198,10 +159,7 @@ class THtmlWriter extends TComponent implements ITextWriter
public function addStyleAttribute($name,$value)
{
- if(isset(self::$_styleEncode[$name]))
- $this->_styles[$name]=THttpUtility::htmlEncode($value);
- else
- $this->_styles[$name]=$value;
+ $this->_styles[$name]=isset(self::$_styleEncode[$name])?THttpUtility::htmlEncode($value):$value;
}
public function flush()
diff --git a/framework/Web/UI/TTemplateManager.php b/framework/Web/UI/TTemplateManager.php
index 7aa6f3b0..21a01b25 100644
--- a/framework/Web/UI/TTemplateManager.php
+++ b/framework/Web/UI/TTemplateManager.php
@@ -317,6 +317,7 @@ class TTemplate extends TComponent implements ITemplate
*/
protected function configureEvent($component,$name,$value)
{
+ $value=THttpUtility::htmlDecode($value);
if(strpos($value,'.')===false)
$component->attachEventHandler($name,array($component,'TemplateControl.'.$value));
else
@@ -336,27 +337,28 @@ class TTemplate extends TComponent implements ITemplate
$setter='set'.$name;
if(is_array($value))
{
+ $v=THttpUtility::htmlDecode($value[1]);
switch($value[0])
{
case self::CONFIG_DATABIND:
- $component->bindProperty($name,$value[1]);
+ $component->bindProperty($name,$v);
break;
case self::CONFIG_EXPRESSION:
- $component->$setter($component->evaluateExpression($value[1]));
+ $component->$setter($component->evaluateExpression($v));
break;
case self::CONFIG_ASSET: // asset URL
- $url=$this->_assetManager->publishFilePath($this->_contextPath.'/'.$value[1]);
+ $url=$this->_assetManager->publishFilePath($this->_contextPath.'/'.$v);
$component->$setter($url);
break;
case self::CONFIG_PARAMETER: // application parameter
- $component->$setter(Prado::getApplication()->getParameters()->itemAt($value[1]));
+ $component->$setter(Prado::getApplication()->getParameters()->itemAt($v));
break;
default: // an error if reaching here
break;
}
}
else
- $component->$setter($value);
+ $component->$setter(THttpUtility::htmlDecode($value));
}
else
throw new TTemplateRuntimeException('template_property_readonly',get_class($component),$name);
@@ -372,27 +374,28 @@ class TTemplate extends TComponent implements ITemplate
{
if(is_array($value))
{
+ $v=THttpUtility::htmlDecode($value[1]);
switch($value[0])
{
case self::CONFIG_DATABIND: // databinding
- $component->bindProperty($name,$value[1]);
+ $component->bindProperty($name,$v);
break;
case self::CONFIG_EXPRESSION: // expression
- $component->setSubProperty($name,$component->evaluateExpression($value[1]));
+ $component->setSubProperty($name,$component->evaluateExpression($v));
break;
case self::CONFIG_ASSET: // asset URL
- $url=$this->_assetManager->publishFilePath($this->_contextPath.'/'.$value[1]);
+ $url=$this->_assetManager->publishFilePath($this->_contextPath.'/'.$v);
$component->setSubProperty($name,$url);
break;
case self::CONFIG_PARAMETER: // application parameter
- $component->setSubProperty($name,Prado::getApplication()->getParameters()->itemAt($value[1]));
+ $component->setSubProperty($name,Prado::getApplication()->getParameters()->itemAt($v));
break;
default: // an error if reaching here
break;
}
}
else
- $component->setSubProperty($name,$value);
+ $component->setSubProperty($name,THttpUtility::htmlDecode($value));
}
/**