X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FLinkFilter.php;h=214f49591ffddc2c6bb4173787acbf720cd13eae;hb=62ac6f372241cef4e8671d0beb33b476ced9a750;hp=85bafcaef65d25b5a1d36339919fa39843f0d49f;hpb=7a693662883ae93728a21176b12b1173ff7c3e45;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/LinkFilter.php b/includes/LinkFilter.php index 85bafcaef6..214f49591f 100644 --- a/includes/LinkFilter.php +++ b/includes/LinkFilter.php @@ -1,9 +1,30 @@ anyString() ); } elseif ( $prot == 'mailto:' ) { // domainpart of email adress only. do not add '.' $host = strtolower( implode( '.', array_reverse( explode( '.', $host ) ) ) ); - $like = "$prot$host%"; + $like = array( "$prot$host", $db->anyString() ); } else { $host = strtolower( implode( '.', array_reverse( explode( '.', $host ) ) ) ); if ( substr( $host, -1, 1 ) !== '.' ) { $host .= '.'; } - $like = "$prot$host"; + $like = array( "$prot$host" ); if ( $subdomains ) { - $like .= '%'; + $like[] = $db->anyString(); } if ( !$subdomains || $path !== '/' ) { - $like .= $path . '%'; + $like[] = $path; + $like[] = $db->anyString(); } } return $like; } + + /** + * Filters an array returned by makeLikeArray(), removing everything past first pattern placeholder. + * + * @param $arr array: array to filter + * @return array filtered array + */ + public static function keepOneWildcard( $arr ) { + if( !is_array( $arr ) ) { + return $arr; + } + + foreach( $arr as $key => $value ) { + if ( $value instanceof LikeMatch ) { + return array_slice( $arr, 0, $key + 1 ); + } + } + + return $arr; + } } -?>