Skip to content

Commit

Permalink
Fixed improper Markdown escaping for some tooltips
Browse files Browse the repository at this point in the history
  • Loading branch information
fguillot committed Apr 29, 2016
1 parent a34f83f commit 9fa8f63
Show file tree
Hide file tree
Showing 11 changed files with 30 additions and 9 deletions.
1 change: 1 addition & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Improvements:

Bug fixes:

* Fixed improper Markdown escaping for some tooltips
* Closing all tasks by column, also update closed tasks
* Fixed wrong task link generation within Markdown text
* Fixed wrong URL on comment toggle link for sorting
Expand Down
12 changes: 12 additions & 0 deletions app/Helper/TextHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,18 @@ public function markdown($text, $isPublicLink = false)
return $parser->text($text);
}

/**
* Escape Markdown text that need to be stored in HTML attribute
*
* @access public
* @param string $text
* @return mixed
*/
public function markdownAttribute($text)
{
return htmlentities($this->markdown($text), ENT_QUOTES, 'UTF-8');
}

/**
* Format a file size
*
Expand Down
2 changes: 1 addition & 1 deletion app/Template/app/projects.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

<?= $this->url->link($this->text->e($project['name']), 'board', 'show', array('project_id' => $project['id'])) ?>
<?php if (! empty($project['description'])): ?>
<span class="tooltip" title='<?= $this->text->e($this->text->markdown($project['description'])) ?>'>
<span class="tooltip" title="<?= $this->text->markdownAttribute($project['description']) ?>">
<i class="fa fa-info-circle"></i>
</span>
<?php endif ?>
Expand Down
2 changes: 1 addition & 1 deletion app/Template/board/table_column.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
</span>

<?php if (! $not_editable && ! empty($column['description'])): ?>
<span class="tooltip pull-right" title='<?= $this->text->e($this->text->markdown($column['description'])) ?>'>
<span class="tooltip pull-right" title="<?= $this->text->markdownAttribute($column['description']) ?>">
&nbsp;<i class="fa fa-info-circle"></i>
</span>
<?php endif ?>
Expand Down
4 changes: 2 additions & 2 deletions app/Template/board/task_footer.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
array('task_id' => $task['id'], 'project_id' => $task['project_id']),
false,
'popover' . (! empty($task['category_description']) ? ' tooltip' : ''),
! empty($task['category_description']) ? $this->text->markdown($task['category_description']) : t('Change category')
! empty($task['category_description']) ? $this->text->markdownAttribute($task['category_description']) : t('Change category')
) ?>
<?php endif ?>
</span>
Expand Down Expand Up @@ -76,7 +76,7 @@
<i class="fa fa-flag flag-milestone"></i>
</span>
<?php endif ?>

<?= $this->hook->render('template:board:task:icons', array('task' => $task)) ?>

<?= $this->task->formatPriority($project, $task) ?>
Expand Down
2 changes: 1 addition & 1 deletion app/Template/column/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class="columns-table table-stripped"
<i class="fa fa-arrows-alt draggable-row-handle" title="<?= t('Change column position') ?>"></i>
<?= $this->text->e($column['title']) ?>
<?php if (! empty($column['description'])): ?>
<span class="tooltip" title='<?= $this->text->e($this->text->markdown($column['description'])) ?>'>
<span class="tooltip" title="<?= $this->text->markdownAttribute($column['description']) ?>">
<i class="fa fa-info-circle"></i>
</span>
<?php endif ?>
Expand Down
2 changes: 1 addition & 1 deletion app/Template/header.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<?= $this->text->e($title) ?>
</span>
<?php if (! empty($description)): ?>
<span class="tooltip" title='<?= $this->text->e($this->text->markdown($description)) ?>'>
<span class="tooltip" title="<?= $this->text->markdownAttribute($description) ?>">
<i class="fa fa-info-circle"></i>
</span>
<?php endif ?>
Expand Down
2 changes: 1 addition & 1 deletion app/Template/project/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
<?php endif ?>

<?php if (! empty($project['description'])): ?>
<span class="tooltip" title='<?= $this->text->e($this->text->markdown($project['description'])) ?>'>
<span class="tooltip" title="<?= $this->text->markdownAttribute($project['description']) ?>">
<i class="fa fa-info-circle"></i>
</span>
<?php endif ?>
Expand Down
2 changes: 1 addition & 1 deletion app/Template/project/show.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
<td>
<?= $this->text->e($column['title']) ?>
<?php if (! empty($column['description'])): ?>
<span class="tooltip" title='<?= $this->text->e($this->text->markdown($column['description'])) ?>'>
<span class="tooltip" title="<?= $this->text->markdownAttribute($column['description']) ?>">
<i class="fa fa-info-circle"></i>
</span>
<?php endif ?>
Expand Down
2 changes: 1 addition & 1 deletion app/Template/swimlane/table.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class="swimlanes-table table-stripped"
<?= $this->text->e($swimlane['name']) ?>

<?php if (! empty($swimlane['description'])): ?>
<span class="tooltip" title='<?= $this->text->e($this->text->markdown($swimlane['description'])) ?>'>
<span class="tooltip" title="<?= $this->text->markdownAttribute($swimlane['description']) ?>">
<i class="fa fa-info-circle"></i>
</span>
<?php endif ?>
Expand Down
8 changes: 8 additions & 0 deletions tests/units/Helper/TextHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@ public function testMarkdownUserLink()
$this->assertEquals('<p>Text @admin @notfound</p>', $h->markdown('Text @admin @notfound', true));
}

public function testMarkdownAttribute()
{
$helper = new TextHelper($this->container);
$this->assertEquals('&lt;p&gt;&Ccedil;a marche&lt;/p&gt;', $helper->markdownAttribute('Ça marche'));
$this->assertEquals('&lt;p&gt;Test with &amp;quot;double quotes&amp;quot;&lt;/p&gt;', $helper->markdownAttribute('Test with "double quotes"'));
$this->assertEquals('&lt;p&gt;Test with &#039;single quotes&#039;&lt;/p&gt;', $helper->markdownAttribute("Test with 'single quotes'"));
}

public function testFormatBytes()
{
$h = new TextHelper($this->container);
Expand Down

0 comments on commit 9fa8f63

Please sign in to comment.