Fork me on GitHub
Subscribe 3

Ticket #1088 (open enhancement)

Change of regexs for bb-codes

  • Created: 2016-06-22 15:29:23
  • Reported by: Visman
  • Assigned to: None
  • Milestone: 1.5.11
  • Component: parser
  • Priority: normal

For url:

	$pattern_callback[] = '%\[url\]([^\[]*?)\[/url\]%';
	$pattern_callback[] = '%\[url=([^\[]+?)\](.*?)\[/url\]%';

-->

	$pattern_callback[] = '%\[url\]([^\x00-\x1f\s]+?)\[/url\]%';
	$pattern_callback[] = '%\[url=([^\x00-\x1f\s]+?)\](.*?)\[/url\]%';

For email:

	$pattern[] = '%\[email\]([^\[]*?)\[/email\]%';
	$pattern[] = '%\[email=([^\[]+?)\](.*?)\[/email\]%';

-->

	$pattern[] = '%\[email\]([^\x00-\x1f\s]+?@[^\x00-\x1f\s]+?)\[/email\]%';
	$pattern[] = '%\[email=([^\x00-\x1f\s]+?@[^\x00-\x1f\s]+?)\](.*?)\[/email\]%';

History

Franz 2016-06-23 04:20:07

  • Milestone set to 1.5.11.

Could you explain the rationale behind this change?

Visman 2016-07-22 15:37:11

For quote bb-code:

		$text = preg_replace_callback('%\[quote=(&quot;|&\#039;|"|\'|)([^\r\n]*?)\\1\]%s', create_function('$matches', 'global $lang_common; return "</p><div class=\"quotebox\"><cite>".str_replace(array(\'[\', \'\\"\'), array(\'&#91;\', \'"\'), $matches[2])." ".$lang_common[\'wrote\']."</cite><blockquote><div><p>";'), $text);

replace -->

		$text = preg_replace('%\[quote=(?P<quote>(?:&quot;|&\#039;|"|\'))?((?(quote)[^\r\n]+?|[^\r\n\]]++))(?(quote)(?P=quote))\]\s*%', '</p><div class="quotebox"><cite>$2 '.$lang_common['wrote'].'</cite><blockquote><div><p>', $text);

test https://fluxbb.org/forums/viewtopic.php?id=8889

Comment edited 1 times (Diff)

Visman 2016-08-06 09:26:40

  • Description changed. (Diff)

Studio384 2016-10-12 10:19:54

It could be me, but the URL and e-mail regexs seem to break it.

Visman 2016-11-27 13:17:30

After tests:
The offered options of regular expressions lead to mistakes in behavior of the parser.

Example:

[quote="][i]"]dd[/i]dd[/quote]
Comment edited 2 times (Diff, Diff 2)