* (bug 4823) Use full parser to extract URLs in ConfirmEdit checks.
[toast/cookiecaptcha.git] / ConfirmEdit.php
index 46b99e8be90f061c6d70b2c4110548ad2c2d1ece..3c90249607b6efa3aa130d7d5cdb5f7af7273ed6 100644 (file)
@@ -446,13 +446,13 @@ class SimpleCaptcha {
         * @return array of strings
         */
        function findLinks( $text ) {
-               $regex = '/((?:' . HTTP_PROTOCOLS . ')' . EXT_LINK_URL_CLASS . '+)/';
+               global $wgParser, $wgTitle, $wgUser;
                
-               if( preg_match_all( $regex, $text, $matches, PREG_PATTERN_ORDER ) ) {
-                       return $matches[1];
-               } else {
-                       return array();
-               }
+               $options = new ParserOptions();
+               $text = $wgParser->preSaveTransform( $text, $wgTitle, $wgUser, $options );
+               $out = $wgParser->parse( $text, $wgTitle, $options );
+               
+               return array_keys( $out->getExternalLinks() );
        }
        
        /**