Skip to content

Commit

Permalink
Fix that an object's notes and action url label is escaped twice
Browse files Browse the repository at this point in the history
fixes #10218
  • Loading branch information
Johannes Meyer committed Sep 28, 2015
1 parent d4c1ca9 commit d627f41
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ class NavigationItemRenderer
*/
protected $internalLinkTargets;

/**
* Whether to escape the label
*
* @var bool
*/
protected $escapeLabel;

/**
* Create a new NavigationItemRenderer
*
Expand Down Expand Up @@ -126,6 +133,29 @@ public function getItem()
return $this->item;
}

/**
* Set whether to escape the label
*
* @param bool $state
*
* @return $this
*/
public function setEscapeLabel($state = true)
{
$this->escapeLabel = (bool) $state;
return $this;
}

/**
* Return whether to escape the label
*
* @return bool
*/
public function getEscapeLabel()
{
return $this->escapeLabel !== null ? $this->escapeLabel : true;
}

/**
* Render the given navigation item as HTML anchor
*
Expand All @@ -144,7 +174,9 @@ public function render(NavigationItem $item = null)
);
}

$label = $this->view()->escape($item->getLabel());
$label = $this->getEscapeLabel()
? $this->view()->escape($item->getLabel())
: $item->getLabel();
if (($icon = $item->getIcon()) !== null) {
$label = $this->view()->icon($icon) . $label;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ foreach ($object->getActionUrls() as $i => $link) {
'Action ' . ($i + 1) . $newTabInfo,
array(
'url' => $link,
'target' => '_blank'
'target' => '_blank',
'renderer' => array(
'NavigationItemRenderer',
'escape_label' => false
)
)
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ if (! empty($links)) {
$this->escape($link) . $newTabInfo,
array(
'url' => $link,
'target' => '_blank'
'target' => '_blank',
'renderer' => array(
'NavigationItemRenderer',
'escape_label' => false
)
)
);
}
Expand Down

0 comments on commit d627f41

Please sign in to comment.