| 771 | | // @@@ regex accepts NO non-whitespace before whitespace, surely not correct? [[ something]] |
| 772 | | else if (preg_match("/^\[\[(\S*)(\s+(.+))?\]\]$/s", $thing, $matches)) # recognize forced links across lines |
| 773 | | { |
| 774 | | if (!isset($matches[1])) $matches[1] = ''; #38 |
| 775 | | if (!isset($matches[3])) $matches[3] = ''; #38 |
| 776 | | list (, $url, , $text) = $matches; |
| | 772 | else if(preg_match("/^\[\[(.*?)\]\]$/s", $thing, $matches)) |
| | 773 | { |
| | 774 | $contents = $matches[1]; |
| | 775 | if(empty($contents) || !isset($contents)) |
| | 776 | return ""; |
| | 777 | |
| | 778 | // Case 1: Deprecated...(first part is a URL followed by |
| | 779 | // one or more whitespaces) |
| | 780 | if (preg_match("/^((http|https|ftp|news|irc|gopher):\/\/([^\|\\s\"<>]+))\s+([^\|]+)$/s", $contents, $matches)) # recognize forced links across lines |
| | 781 | { |
| | 782 | if (!isset($matches[1])) $matches[1] = ''; #38 |
| | 783 | if (!isset($matches[4])) $matches[4] = ''; #38 |
| | 784 | $url = $matches[1]; |
| | 785 | $text = $matches[4]; |
| | 786 | } |
| | 787 | |
| | 788 | // Case 2: Deprecated...(first part is a CC string |
| | 789 | // followed by one or more whitespaces) |
| | 790 | else if(preg_match("/^(.*?)\s+([^|]+)$/s", $contents, $matches) && |
| | 791 | preg_match(VALID_PAGENAME_PATTERN, $matches[1])) |
| | 792 | { |
| | 793 | $url = $matches[1]; |
| | 794 | $text = $matches[2]; |
| | 795 | } |
| | 796 | |
| | 797 | // Case 3: If no "|" exists in $contents, assume the match |
| | 798 | // refers to an internal page |
| | 799 | else if(preg_match("/^([^\|]+)$/s", $contents, $matches)) |
| | 800 | { |
| | 801 | $url = $matches[1]; |
| | 802 | $text = $matches[1]; |
| | 803 | } |
| | 804 | |
| | 805 | // Case 4: If a "|" symbol exists, assume two parts, a URL and |
| | 806 | // text |
| | 807 | else if(preg_match("/^(.*?)\s*\|\s*(.*?)$/s", $contents, $matches)) |
| | 808 | { |
| | 809 | if (!isset($matches[1])) $matches[1] = ''; |
| | 810 | if (!isset($matches[2])) $matches[2] = ''; |
| | 811 | $url = $matches[1]; |
| | 812 | $text = $matches[2]; |
| | 813 | } |
| | 814 | |