Commit 50da3d8b authored by Son Nguyen's avatar Son Nguyen

Bug 1579145: Allow links in file description

behatnotneeded

Change-Id: Ic0f9ffacdc47b7c393e3f4dd282999b69e2e01c7
parent 5c84ffca
......@@ -3348,6 +3348,27 @@ function hsc ($text) {
return htmlspecialchars($text, ENT_COMPAT, 'UTF-8');
}
/**
* Returns a string of full formatted URLs
* www.something -> http://www.something
* something.[com|org] -> http://www.something.[com|org]
*
* @param string $urls
* @return string The full formatted URLs
*/
function add_http ($urls) {
$reg_exUrl = "/(\.*|(http|https|ftp|ftps)\:\/\/)([a-zA-Z0-9\-\.]+)\.[a-zA-Z]{2,3}(\/\S*)?/i";
if (preg_match_all($reg_exUrl, $urls, $m)) {
for ($i=0; $i < count($m[0]); $i++) {
if (empty($m[1][$i])) {
$urls = preg_replace("~{$m[0][$i]}~", "http://$0", $urls);
}
}
}
return $urls;
}
/**
* Builds the pieform for the search field in the page header
*/
......
......@@ -29,10 +29,14 @@
{if $file.description}
<div class="file-description">
<p class="text-small">
{$file.description}
{$file.description|safe|add_http|clean_html}
</p>
</div>
<script type="application/javascript">
jQuery("div.file-description a").addClass('inner-link');
</script>
{/if}
</li>
{/foreach}
</ul>
......@@ -9,7 +9,7 @@
{if $showdescription && $image.title}
<div class="carousel-caption" id="description_{$instanceid}_{$k}">
{$image.title}
{$image.title|safe|add_http|clean_html}
</div>
{/if}
</div>
......
......@@ -6,7 +6,7 @@
</a>
{if $showdescription && $image.title}
<p class="text-small title">
{$image.title|truncate:60|safe}
{$image.title|truncate:60|safe|add_http|clean_html}
</p>
{/if}
</div>
......
......@@ -6,7 +6,7 @@
</a>
{if $showdescription && $image.title}
<p class="text-small title">
{$image.title|truncate:60|safe}
{$image.title|truncate:60|safe|add_http|clean_html}
</p>
{/if}
</div>
......
......@@ -7,7 +7,7 @@
{if $showdescription}
<div class="detail" itemprop="description">
{$description}
{$description|safe|add_http|clean_html}
</div>
{/if}
</div>
......
......@@ -16,7 +16,7 @@
{if $description}
<tr>
<th>{str tag=Description section=artefact.file}:</th>
<td>{$description}</td>
<td>{$description|safe|add_http|clean_html}</td>
</tr>
{/if}
{if $tags}
......
......@@ -50,8 +50,11 @@
{/if}
{if $child->description}
<p class="file-description text-small text-midtone">
{$child->description}
{$child->description|safe|add_http|clean_html}
</p>
<script type="application/javascript">
jQuery(".file-description a").addClass('inner-link');
</script>
{/if}
</li>
{/foreach}
......
......@@ -85,7 +85,7 @@
{/if}
</td>
<td class="filedescription hidden-xs">
{$file->description}
{$file->description|safe|add_http|clean_html}
{if $showtags}
{if $file->tags}
<div class="tags filetags text-small">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment