Project

General

Profile

Actions

Bug #28248

closed

t3lib_div::substUrlsInPlainText didn't recognize URLs at the end of a sentence correctly

Added by Robert Heel almost 13 years ago. Updated over 5 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
-
Target version:
-
Start date:
2011-07-15
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
4.5
PHP Version:
5.2
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

e.g.
To unsubscribe use http://unsubscribe.com.
detects "http://unsubscribe.com." as URL.

I've shortened the substUrlsInPlainText function:

function substUrlsInPlainText($message,$urlmode='76',$index_script_url='') {
return preg_replace('/(http|https):\/\/.+(?=[\]\.\?]*([\! \'"()<>]+|$))/eiU','self::makeRedirectUrl("\\0",'.intval($urlmode).',"'.$index_script_url.'")',$message);
}

The regex:
(http|https):\/\/.+ -> Everything which starts with http:// or https://
(?=[\]\.\?]* -> and not end with "]", "." or "?" (these are also allowed in the url)
([\! \'"()<>]+|$)) -> and end with one of these is an url...

I've checked this with the following messages:
'http://only-url.com',
'https://only-secure-url.com',
'A http://url in the sentence.',
'URL in round brackets (http://www.example.com) in the sentence.',
'URL in square brackets [http://www.example.com/a/b.php?c[d]=e] in the sentence.',
'URL in square brackets at the end of the sentence [http://www.example.com/a/b.php?c[d]=e].',
'Square brackets in the http://www.url.com?tt_news[uid]=1',
'URL with http://dot.com.',
'URL in <a href="http://www.example.com/&quot;&gt;a tag</a>',
'URL in HTML <b>http://www.example.com&lt;/b&gt;&lt;br />',
'URL with http://username@example.com/',
'URL in quotation marks "http://example.com"',
'URL with umlauts http://müller.de',
'Secret in URL http://username:secret@example.com',
'Multiline
text with a http://url.com',
'http://www.shout.com!',
'And last but not least http://www.two.com/abc http://urls.com/abc?x=1&y=2',


Files

substUrlsInPlainText.diff (1.28 KB) substUrlsInPlainText.diff Robert Heel, 2011-07-15 23:33

Related issues 1 (0 open1 closed)

Related to TYPO3 Core - Bug #14268: function substUrlsInPlainText in class.t3lib_div.php cant extract properly an url with char other than space at endClosedWolfgang Klinger2004-08-12

Actions
Actions #1

Updated by Mr. Hudson almost 13 years ago

Patch set 1 of change Ic5cc35546602e1d626f88f2cd64b9030f31780d6 has been pushed to the review server.
It is available at http://review.typo3.org/3383

Actions #2

Updated by Mr. Hudson almost 13 years ago

Patch set 2 of change Ic5cc35546602e1d626f88f2cd64b9030f31780d6 has been pushed to the review server.
It is available at http://review.typo3.org/3383

Actions #3

Updated by Tolleiv Nietsch almost 13 years ago

  • Status changed from New to Under Review
Actions #4

Updated by Gerrit Code Review about 12 years ago

Patch set 3 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/3383

Actions #5

Updated by Gerrit Code Review about 12 years ago

Patch set 4 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/3383

Actions #6

Updated by Gerrit Code Review about 12 years ago

Patch set 1 for branch TYPO3_4-7 has been pushed to the review server.
It is available at http://review.typo3.org/10537

Actions #7

Updated by Gerrit Code Review about 12 years ago

Patch set 1 for branch TYPO3_4-6 has been pushed to the review server.
It is available at http://review.typo3.org/10538

Actions #8

Updated by Gerrit Code Review about 12 years ago

Patch set 1 for branch TYPO3_4-5 has been pushed to the review server.
It is available at http://review.typo3.org/10539

Actions #9

Updated by Robert Heel about 12 years ago

  • Status changed from Under Review to Resolved
  • % Done changed from 30 to 100
Actions #10

Updated by Gerrit Code Review over 11 years ago

  • Status changed from Resolved to Under Review

Patch set 1 for branch TYPO3_4-7 has been pushed to the review server.
It is available at http://review.typo3.org/13103

Actions #11

Updated by Gerrit Code Review over 11 years ago

Patch set 2 for branch TYPO3_4-6 has been pushed to the review server.
It is available at http://review.typo3.org/10538

Actions #12

Updated by Robert Heel over 11 years ago

  • Status changed from Under Review to Resolved
Actions #13

Updated by Stig Nørgaard Færch over 10 years ago

I still have this problem with 4.5.29 and 4.5.30.

Actions #14

Updated by Benni Mack over 5 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF