Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

linkify strips consecutive line breaks #305

Open
dariusj18 opened this issue Apr 13, 2020 · 1 comment
Open

linkify strips consecutive line breaks #305

dariusj18 opened this issue Apr 13, 2020 · 1 comment

Comments

@dariusj18
Copy link

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 dariusj18 added the bug label Apr 13, 2020
@atymic
Copy link
Owner

atymic commented Jun 22, 2020

Feel free to PR a fix to the regex :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants