Make HTML tag searches for `<code>` and `<pre>` case-insensitive in `make_clickable()`.

Props bpetty.
Fixes #23756.



git-svn-id: https://develop.svn.wordpress.org/trunk@26094 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Scott Taylor 2013-11-11 21:53:08 +00:00
parent 8120f2861c
commit 2ccc101050
2 changed files with 5 additions and 5 deletions

View File

@ -1609,9 +1609,9 @@ function make_clickable( $text ) {
$nested_code_pre = 0; // Keep track of how many levels link is nested inside <pre> or <code>
foreach ( $textarr as $piece ) {
if ( preg_match( '|^<code[\s>]|', $piece ) || preg_match( '|^<pre[\s>]|', $piece ) )
if ( preg_match( '|^<code[\s>]|i', $piece ) || preg_match( '|^<pre[\s>]|i', $piece ) )
$nested_code_pre++;
elseif ( ( '</code>' === $piece || '</pre>' === $piece ) && $nested_code_pre )
elseif ( ( '</code>' === strtolower( $piece ) || '</pre>' === strtolower( $piece ) ) && $nested_code_pre )
$nested_code_pre--;
if ( $nested_code_pre || empty( $piece ) || ( $piece[0] === '<' && ! preg_match( '|^<\s*[\w]{1,20}+://|', $piece ) ) ) {

View File

@ -301,7 +301,7 @@ class Tests_Formatting_MakeClickable extends WP_UnitTestCase {
'<codecustomtag>http://wordpress.org</codecustomtag>',
'URL before pre http://wordpress.org<pre>http://wordpress.org</pre>',
'URL before code http://wordpress.org<code>http://wordpress.org</code>',
'URL after pre <pre>http://wordpress.org</pre>http://wordpress.org',
'URL after pre <PRE>http://wordpress.org</PRE>http://wordpress.org',
'URL after code <code>http://wordpress.org</code>http://wordpress.org',
'URL before and after pre http://wordpress.org<pre>http://wordpress.org</pre>http://wordpress.org',
'URL before and after code http://wordpress.org<code>http://wordpress.org</code>http://wordpress.org',
@ -317,7 +317,7 @@ class Tests_Formatting_MakeClickable extends WP_UnitTestCase {
'<codecustomtag><a href="http://wordpress.org" rel="nofollow">http://wordpress.org</a></codecustomtag>',
'URL before pre <a href="http://wordpress.org" rel="nofollow">http://wordpress.org</a><pre>http://wordpress.org</pre>',
'URL before code <a href="http://wordpress.org" rel="nofollow">http://wordpress.org</a><code>http://wordpress.org</code>',
'URL after pre <pre>http://wordpress.org</pre><a href="http://wordpress.org" rel="nofollow">http://wordpress.org</a>',
'URL after pre <PRE>http://wordpress.org</PRE><a href="http://wordpress.org" rel="nofollow">http://wordpress.org</a>',
'URL after code <code>http://wordpress.org</code><a href="http://wordpress.org" rel="nofollow">http://wordpress.org</a>',
'URL before and after pre <a href="http://wordpress.org" rel="nofollow">http://wordpress.org</a><pre>http://wordpress.org</pre><a href="http://wordpress.org" rel="nofollow">http://wordpress.org</a>',
'URL before and after code <a href="http://wordpress.org" rel="nofollow">http://wordpress.org</a><code>http://wordpress.org</code><a href="http://wordpress.org" rel="nofollow">http://wordpress.org</a>',