twitter icon indicating copy to clipboard operation
twitter copied to clipboard

linkify strips consecutive line breaks

Open dariusj18 opened this issue 5 years ago • 1 comments

Describe the bug Twitter::linkify() has the line $text = preg_replace('/\s+/', ' ', $text);. This strips out consecutive line breaks. I'm not sure why the linkify tries to remove extra spaces, but at the least it should probably limit it to space (ascii 32) characters.

To Reproduce Steps to reproduce the behavior:

  1. Retrieve a tweet with consecutive line breaks ex. \n\n
  2. Run Twitter::linkify($tweet)
  3. See that it strips the line breaks out, preventing using nl2br() to show the tweet as written.

Expected behavior Leave line breaks in the returned string.

Version 2.2.11

Additional context This may be because the tweet is retrieved via "tweet_mode = extended", perhaps the linkify could contextually strip out spaces or not if the tweet has the text property vs. the full_text property.

dariusj18 avatar Apr 13 '20 21:04 dariusj18

Feel free to PR a fix to the regex :)

atymic avatar Jun 22 '20 00:06 atymic