dépôts
/
lhc
/
web
/
wiklou.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge "parser: Validate $length in padleft/padright parser functions"
[lhc/web/wiklou.git]
/
includes
/
LinkFilter.php
diff --git
a/includes/LinkFilter.php
b/includes/LinkFilter.php
index
790e2be
..
17b4d56
100644
(file)
--- a/
includes/LinkFilter.php
+++ b/
includes/LinkFilter.php
@@
-38,9
+38,10
@@
class LinkFilter {
*
* @param Content $content Content to check
* @param string $filterEntry Domainparts, see makeRegex() for more details
*
* @param Content $content Content to check
* @param string $filterEntry Domainparts, see makeRegex() for more details
+ * @param string $protocol 'http://' or 'https://'
* @return int 0 if no match or 1 if there's at least one match
*/
* @return int 0 if no match or 1 if there's at least one match
*/
-
static function matchEntry( Content $content, $filterEntry
) {
+
public static function matchEntry( Content $content, $filterEntry, $protocol = 'http://'
) {
if ( !( $content instanceof TextContent ) ) {
// TODO: handle other types of content too.
// Maybe create ContentHandler::matchFilter( LinkFilter ).
if ( !( $content instanceof TextContent ) ) {
// TODO: handle other types of content too.
// Maybe create ContentHandler::matchFilter( LinkFilter ).
@@
-50,7
+51,7
@@
class LinkFilter {
$text = $content->getNativeData();
$text = $content->getNativeData();
- $regex = self::makeRegex( $filterEntry );
+ $regex = self::makeRegex( $filterEntry
, $protocol
);
return preg_match( $regex, $text );
}
return preg_match( $regex, $text );
}
@@
-59,10
+60,12
@@
class LinkFilter {
*
* @param string $filterEntry URL, if it begins with "*.", it'll be
* replaced to match any subdomain
*
* @param string $filterEntry URL, if it begins with "*.", it'll be
* replaced to match any subdomain
+ * @param string $protocol 'http://' or 'https://'
+ *
* @return string Regex pattern, for preg_match()
*/
* @return string Regex pattern, for preg_match()
*/
- private static function makeRegex( $filterEntry ) {
- $regex = '!
http://'
;
+ private static function makeRegex( $filterEntry
, $protocol
) {
+ $regex = '!
' . preg_quote( $protocol )
;
if ( substr( $filterEntry, 0, 2 ) == '*.' ) {
$regex .= '(?:[A-Za-z0-9.-]+\.|)';
$filterEntry = substr( $filterEntry, 2 );
if ( substr( $filterEntry, 0, 2 ) == '*.' ) {
$regex .= '(?:[A-Za-z0-9.-]+\.|)';
$filterEntry = substr( $filterEntry, 2 );