Polls: Allow linebreaks in poll description and comments

Created on 3 Feb 2019  路  4Comments  路  Source: nextcloud/polls

It is not possible to add a newline in the output of the poll-description and in comments

If you add <br> it will shown as code there and if you add a line break, it are cut out completely of the output, not even replaced with a space, so the last character and the first of the new line glue together without space.

I can think of two solutions:

  1. allow <br> in comments and the description
  2. or render new lines as a visible New line in the output
  3. Allow markdown as in announcementcenter

I prefer the first or third solutions, the first is easy to achieve with PHP strip_tags, Example:

// allow <br> <p> and <a>:
echo strip_tags($text, '<br><p><a>');
enhancement

Most helpful comment

HTML tags in the description are nearly a running gag. We had many problems including possible vulnerability. I think, this is something worth to be done in the migration of the vote page. After that things get a little bit easier.

All 4 comments

It is strange, cause this line already looks like it wouls show a BR in place of a new line:

https://github.com/nextcloud/polls/blob/master/templates/vote.tmpl.php#L96

        $description = str_replace(array('\r\n', '\r', '\n'), '<br/>', htmlspecialchars($poll->getDescription()));

The function getDescription is not in the Polls-sourcecode, so it may be a bug in another project?

I could think of a solution like this: add this line after the first str_replace:

        $description = preg_replace('/&lt;[bBrR]艧*\/*&gt;/', '<br/>', $description);

HTML tags in the description are nearly a running gag. We had many problems including possible vulnerability. I think, this is something worth to be done in the migration of the vote page. After that things get a little bit easier.

Allowing Markdown would be really nice

325

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dartcafe picture dartcafe  路  4Comments

Dubidubiduu picture Dubidubiduu  路  5Comments

nextgen-networks picture nextgen-networks  路  6Comments

xeiss picture xeiss  路  4Comments

dartcafe picture dartcafe  路  4Comments