diff --git a/src/ajax.php b/src/ajax.php
index b9ab8bf..03e1d7d 100644
--- a/src/ajax.php
+++ b/src/ajax.php
@@ -532,7 +532,8 @@ function prepareTaskRow($r)
return array(
'id' => $r['id'],
- 'title' => htmlspecialchars( $r['title'] ),
+ 'title' => titleMarkup( $r['title'] ),
+ 'titleText' => (string)$r['title'],
'listId' => $r['list_id'],
'date' => htmlarray($dCreated),
'dateInt' => (int)$r['d_created'],
diff --git a/src/includes/markup.php b/src/includes/markup.php
index 082122e..dd616c3 100644
--- a/src/includes/markup.php
+++ b/src/includes/markup.php
@@ -31,17 +31,47 @@ function mttMarkup_v1($s)
$s = preg_replace("~([\s\S]*?)~i", "${c1}i${c2}\$1${c1}/i${c2}", $s);
$s = preg_replace("~([\s\S]*?)~i", "${c1}u${c2}\$1${c1}/u${c2}", $s);
$s = preg_replace("~([\s\S]*?)~i", "${c1}s${c2}\$1${c1}/s${c2}", $s);
- $s = htmlspecialchars($s); //escape all elements, except above
+ $s = htmlspecialchars($s, ENT_QUOTES); //escape all elements, except above
$s = str_replace( [$c1, $c2], ['<','>'], $s ); //unhide
$s = nl2br($s);
// make links from text starting with 'www.'
- $s = preg_replace( "/(^|\s|>)(www\.([\w\#$%&~\/.\-\+;:=,\?\[\]@]+?))(,|\.|:|)?(?=\s|"|<|>|\"|<|>|$)/i" , '$1$2$4' , $s );
+ $s = preg_replace(
+ "/(^|\s|>)(www\.([\w\#$%&~\/.\-\+;:=,\?\[\]@]+?))(,|\.|:|)?(?=\s|"|<|>|\"|<|>|$)/iu" ,
+ '$1$2$4' ,
+ $s
+ );
// make link from text starting with protocol like 'http://'
- $s = preg_replace( "/(^|\s|>)([a-z]+:\/\/([\w\#$%&~\/.\-\+;:=,\?\[\]@]+?))(,|\.|:|)?(?=\s|"|<|>|\"|<|>|$)/i" , '$1$2$4' , $s);
+ $s = preg_replace(
+ "/(^|\s|>)([a-z]+:\/\/([\w\#$%&~\/.\-\+;:=,\?\[\]@]+?))(,|\.|:|)?(?=\s|"|<|>|\"|<|>|$)/iu" ,
+ '$1$2$4' ,
+ $s
+ );
return $s;
}
+// Convert raw title to html with allowed urls
+function titleMarkup($title)
+{
+ //escape all unsafe
+ $title = htmlspecialchars($title, ENT_QUOTES);
+
+ // make links from text starting with 'www.'
+ $title = preg_replace(
+ "/(^|\s|>)(www\.([\w\#$%&~\/.\-\+;:=,\?\[\]@]+?))(,|\.|:|)?(?=\s|"|<|>|\"|<|>|$)/iu" ,
+ '$1$2$4' ,
+ $title
+ );
+
+ // make link from text starting with protocol like 'http://'
+ $title = preg_replace(
+ "/(^|\s|>)([a-z]+:\/\/([\w\#$%&~\/.\-\+;:=,\?\[\]@]+?))(,|\.|:|)?(?=\s|"|<|>|\"|<|>|$)/iu" ,
+ '$1$2$4' ,
+ $title
+ );
+ return $title;
+}
+
?>
\ No newline at end of file
diff --git a/src/includes/mytinytodo.js b/src/includes/mytinytodo.js
index 1afb3c2..c131103 100644
--- a/src/includes/mytinytodo.js
+++ b/src/includes/mytinytodo.js
@@ -1496,7 +1496,7 @@ function editTask(id)
if(!item) return false;
// no need to clear form
var form = document.getElementById('taskedit_form');
- form.task.value = dehtml(item.title);
+ form.task.value = item.titleText;
form.note.value = item.noteText;
form.id.value = item.id;
form.tags.value = item.tags.split(',').join(', ');