summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2014-10-30 18:13:46 +0100
committerVincent Petry <pvince81@owncloud.com>2014-10-30 18:13:46 +0100
commitbed81ea854119b1f48d39a5da3381c3eb968838a (patch)
tree43fb50cf3d5a8a4299824fd638ceb747cec8d5a0
parent146c46b73a5b780fafd400dfa1881c14457cb4a2 (diff)
parent510d0b2cf3c108447f42fcb119560175134fb0f6 (diff)
downloadnextcloud-server-bed81ea854119b1f48d39a5da3381c3eb968838a.tar.gz
nextcloud-server-bed81ea854119b1f48d39a5da3381c3eb968838a.zip
Merge pull request #11080 from owncloud/addheader-text-2
Fix the addHeader tag attributes text methods to not ignore the text parameter
-rw-r--r--core/templates/layout.base.php10
-rw-r--r--core/templates/layout.guest.php11
-rw-r--r--core/templates/layout.user.php10
-rw-r--r--lib/private/template.php27
-rw-r--r--lib/private/util.php6
-rw-r--r--lib/public/util.php6
6 files changed, 31 insertions, 39 deletions
diff --git a/core/templates/layout.base.php b/core/templates/layout.base.php
index 3325bc9165e..2b496c23246 100644
--- a/core/templates/layout.base.php
+++ b/core/templates/layout.base.php
@@ -21,15 +21,7 @@
<?php foreach ($_['jsfiles'] as $jsfile): ?>
<script type="text/javascript" src="<?php print_unescaped($jsfile); ?>"></script>
<?php endforeach; ?>
- <?php foreach ($_['headers'] as $header): ?>
- <?php
- print_unescaped('<'.$header['tag'].' ');
- foreach ($header['attributes'] as $name => $value) {
- print_unescaped("$name='$value' ");
- };
- print_unescaped('/>');
- ?>
- <?php endforeach; ?>
+ <?php print_unescaped($_['headers']); ?>
</head>
<body id="body-public">
<noscript><div id="nojavascript"><div><?php print_unescaped($l->t('This application requires JavaScript for correct operation. Please <a href="http://enable-javascript.com/" target="_blank">enable JavaScript</a> and reload the page.')); ?></div></div></noscript>
diff --git a/core/templates/layout.guest.php b/core/templates/layout.guest.php
index 0ad2ea4d807..763af4dc1d2 100644
--- a/core/templates/layout.guest.php
+++ b/core/templates/layout.guest.php
@@ -22,16 +22,7 @@
<?php foreach($_['jsfiles'] as $jsfile): ?>
<script type="text/javascript" src="<?php print_unescaped($jsfile); ?>"></script>
<?php endforeach; ?>
-
- <?php foreach($_['headers'] as $header): ?>
- <?php
- print_unescaped('<'.$header['tag'].' ');
- foreach($header['attributes'] as $name=>$value) {
- print_unescaped("$name='$value' ");
- };
- print_unescaped('/>');
- ?>
- <?php endforeach; ?>
+ <?php print_unescaped($_['headers']); ?>
</head>
<body id="<?php p($_['bodyid']);?>">
<noscript><div id="nojavascript"><div><?php print_unescaped($l->t('This application requires JavaScript for correct operation. Please <a href="http://enable-javascript.com/" target="_blank">enable JavaScript</a> and reload the page.')); ?></div></div></noscript>
diff --git a/core/templates/layout.user.php b/core/templates/layout.user.php
index 6164d16ac17..9f94344b21b 100644
--- a/core/templates/layout.user.php
+++ b/core/templates/layout.user.php
@@ -29,15 +29,7 @@
<?php foreach($_['jsfiles'] as $jsfile): ?>
<script type="text/javascript" src="<?php print_unescaped($jsfile); ?>"></script>
<?php endforeach; ?>
- <?php foreach($_['headers'] as $header): ?>
- <?php
- print_unescaped('<'.$header['tag'].' ');
- foreach($header['attributes'] as $name=>$value) {
- print_unescaped("$name='$value' ");
- };
- print_unescaped('/>');
- ?>
- <?php endforeach; ?>
+ <?php print_unescaped($_['headers']); ?>
</head>
<body id="<?php p($_['bodyid']);?>">
<noscript><div id="nojavascript"><div><?php print_unescaped($l->t('This application requires JavaScript for correct operation. Please <a href="http://enable-javascript.com/" target="_blank">enable JavaScript</a> and reload the page.')); ?></div></div></noscript>
diff --git a/lib/private/template.php b/lib/private/template.php
index fe0cde53ff1..9ad9d5466db 100644
--- a/lib/private/template.php
+++ b/lib/private/template.php
@@ -158,10 +158,15 @@ class OC_Template extends \OC\Template\Base {
* Add a custom element to the header
* @param string $tag tag name of the element
* @param array $attributes array of attributes for the element
- * @param string $text the text content for the element
+ * @param string $text the text content for the element. If $text is null then the
+ * element will be written as empty element. So use "" to get a closing tag.
*/
- public function addHeader( $tag, $attributes, $text='') {
- $this->headers[]=array('tag'=>$tag,'attributes'=>$attributes, 'text'=>$text);
+ public function addHeader($tag, $attributes, $text=null) {
+ $this->headers[]= array(
+ 'tag' => $tag,
+ 'attributes' => $attributes,
+ 'text' => $text
+ );
}
/**
@@ -178,12 +183,22 @@ class OC_Template extends \OC\Template\Base {
$page = new OC_TemplateLayout($this->renderas, $this->app);
// Add custom headers
- $page->assign('headers', $this->headers, false);
+ $headers = '';
foreach(OC_Util::$headers as $header) {
- $page->append('headers', $header);
+ $headers .= '<'.OC_Util::sanitizeHTML($header['tag']);
+ foreach($header['attributes'] as $name=>$value) {
+ $headers .= ' "'.OC_Util::sanitizeHTML($name).'"="'.OC_Util::sanitizeHTML($value).'"';
+ }
+ if ($header['text'] !== null) {
+ $headers .= '>'.OC_Util::sanitizeHTML($header['text']).'</'.OC_Util::sanitizeHTML($header['tag']).'>';
+ } else {
+ $headers .= '/>';
+ }
}
- $page->assign( "content", $data, false );
+ $page->assign('headers', $headers, false);
+
+ $page->assign('content', $data, false );
return $page->fetchPage();
}
else{
diff --git a/lib/private/util.php b/lib/private/util.php
index 9b8a7a5bc40..de4bef4cb8a 100644
--- a/lib/private/util.php
+++ b/lib/private/util.php
@@ -388,13 +388,13 @@ class OC_Util {
/**
* Add a custom element to the header
- *
+ * If $text is null then the element will be written as empty element.
+ * So use "" to get a closing tag.
* @param string $tag tag name of the element
* @param array $attributes array of attributes for the element
* @param string $text the text content for the element
- * @return void
*/
- public static function addHeader($tag, $attributes, $text = '') {
+ public static function addHeader($tag, $attributes, $text=null) {
self::$headers[] = array(
'tag' => $tag,
'attributes' => $attributes,
diff --git a/lib/public/util.php b/lib/public/util.php
index 22ded1d0fc5..a87d26a4004 100644
--- a/lib/public/util.php
+++ b/lib/public/util.php
@@ -147,12 +147,14 @@ class Util {
/**
* Add a custom element to the header
+ * If $text is null then the element will be written as empty element.
+ * So use "" to get a closing tag.
* @param string $tag tag name of the element
* @param array $attributes array of attributes for the element
* @param string $text the text content for the element
*/
- public static function addHeader( $tag, $attributes, $text='') {
- \OC_Util::addHeader( $tag, $attributes, $text );
+ public static function addHeader($tag, $attributes, $text=null) {
+ \OC_Util::addHeader($tag, $attributes, $text);
}
/**