diff --git a/projects/plugins/wpcomsh/changelog/fix-content-clickable b/projects/plugins/wpcomsh/changelog/fix-content-clickable new file mode 100644 index 0000000000000..6da2dba1ca6ba --- /dev/null +++ b/projects/plugins/wpcomsh/changelog/fix-content-clickable @@ -0,0 +1,4 @@ +Significance: patch +Type: fixed + +Fix function that add links to URLs in the page when having HTML attributes with "<" in the value diff --git a/projects/plugins/wpcomsh/tests/test-wpcomsh.php b/projects/plugins/wpcomsh/tests/test-wpcomsh.php index 524d985812021..0357626a8f2c7 100644 --- a/projects/plugins/wpcomsh/tests/test-wpcomsh.php +++ b/projects/plugins/wpcomsh/tests/test-wpcomsh.php @@ -29,6 +29,7 @@ public function test_wpcomsh_make_content_clickable() { $div_skip = '
https://wp.com
'; $custom_element = 'https://wp.com'; $custom_element_starts_with_pre = 'https://wp.com'; + $link_inside_tag_inside_attr = "\n" . '
  • '; $original_content = '' . $script . @@ -40,7 +41,8 @@ public function test_wpcomsh_make_content_clickable() { $textarea . $div_skip . $custom_element . - $custom_element_starts_with_pre; + $custom_element_starts_with_pre . + $link_inside_tag_inside_attr; $expected_output = '' . '' . @@ -52,7 +54,8 @@ public function test_wpcomsh_make_content_clickable() { '' . '
    https://wp.com
    ' . 'https://wp.com' . // Made clickable - 'https://wp.com'; // Made clickable even if it starts with `https://wp.com' . // Made clickable even if it starts with `'; // Don't make clickable if it's inside a tag inside an attribute. $this->assertEquals( $expected_output, wpcomsh_make_content_clickable( $original_content ) ); } diff --git a/projects/plugins/wpcomsh/wpcomsh.php b/projects/plugins/wpcomsh/wpcomsh.php index 92bacc4441469..1c609132d8dc6 100644 --- a/projects/plugins/wpcomsh/wpcomsh.php +++ b/projects/plugins/wpcomsh/wpcomsh.php @@ -387,7 +387,7 @@ function wpcomsh_make_content_clickable( $content ) { // don't look in ,
    ,  and 
     	// use 
    in support docs where linkifying // breaks shortcodes, etc. - $_split = preg_split( '/(<[^<>]+>)/i', $content, -1, PREG_SPLIT_DELIM_CAPTURE ); + $_split = preg_split( '/(<[^>]+>)/i', $content, -1, PREG_SPLIT_DELIM_CAPTURE ); $end = ''; $out = ''; $combine = '';