ÿØÿà JFIF    ÿÛ „  ( %!1"%)+...383-7(-.+  -%%--------+------------/----------------------------ÿÀ  ¶" ÿÄ     ÿÄ @    !1AQaq‘¡"±ÁÑð2’BRráS‚ñ3b¢CT²Ò #cÿÄ    ÿÄ '   1!AQ2a"‘±#ÿÚ   ? ò(/p‘—–¢·,M|¯G»R£üešT. ôŸEoCFñ‡ 4ÔkåóxR|µÁ¨ÓDà!Ç´µ˜‡p ÍQ‹§!þž^õWsŒy  åÁ§$á«%ºq˜™JyyË0y«^Ϗ -3ÃÏËÈ£Æ\P’ä„s&•‹Üs üô'àWt¹pñCp$bÚF`·7.^)¾!)ÒÙ˜–ÅÏš^h¾ø³·ìe±ŒaeÖ—Í,e=B}Jéߦ$$½—šÙÜCC¯¶è8β–Åkèwx LÉngT±æ¹£Ócœ¿Í/©Éÿ ‰ÚCÒ­mq;Tt¶–}0"zÖPcd1š­¤tˆ„ÐÓâqú[™öUCŠ2޿د­É(¸ßúçšmW,Ò ºf‹Ån™ÄLêÁ8üÁkÁ€L¥ÍuJ1œôrÂSŒÓöt!7EUíïb)AËi¬â-ÙHk8òÁiXYwÅ)O^"ÇØriÛô{»wRUKÙÏÚlÓ¬€‚’שT ] ªb—ÊîKC^×M“xùäñz¬zJ× {4[¹M'IÆeH1LCWÕ]œûº WDæà°OÅ‚¹c²ÞuA–rL`HšpCez‡V’— Ž‚Ë„–ñ­'µR0ÕÖ=À:±G»C\nÆÉ5*¢ †3šhQ4ýÒi$Õ1"Ü]¢p-q3zcQ$ªö¨¥æf›‘»´ÝÚHá„e²JÇ–iÊ:·à¬Øc5Åk»Laª*wi [0Ówk ¦a¦0Õ²ÅÅ‚T¸’³q:Æ<¹ú Ò˜Æ}2VE•Ѐp¡Ô3Úº …h³^LJºçì¥Ánó|˜ÖˆÎˆ+« ¦dø‘Mº–d\ªDðÛ„Ì×LÝ——Ð9Ç|•FèçVm™¨€™3õS–9Äå¢<̉Ìm¢±`·º˜&Z²ž Ë®D«¶»6™‰©­HÈ Àá«h­i³04æ’hxœi3ï¨(ÓL·†‹¶ËpŒ ƒÜÒ? :õdsÀ –3æÓ·Üjâ¬9—]8n¼&]I F£¼…ì–—Œ0v°LǐÅfÛ2TÖ’aµ˜N@ÖBSÏ^à´4-±°b×nÈÈœÆD=KdŒø…ÄÈK,›ÖR§fjü$^ÔÎ!„6^ s:Üun\ôkCÞò÷<—Lúl Í›G¹ÀPá¼Nc¡šÒ…ÙWͳœ±vÊáЄ×9‹P‰cEØ‘™›µŸP<×g1 º©Ø¬wiÁ^l5× I/';Ë+´Z‡ÓÄFÕp[Èð’ HÄ ó 9¬Dl4“é±Ï”V=^Hð;žLädÉa‚°Ë,#/Ž~²BÔÛ QãñQtIeórVB,ÏÂf‹4#Μc‹É3ZIÖ Œ¢¥·üxa‡Ãçè„jŠ[5 Ä!U?,3žÎ×…ðdÓ÷háŠA‰ìÄ4÷ÃÜZÃE{‰®+W\ZÍE[‰»µk»MÝ­`¢©†˜ÃV‹-f¢¡†¢a«eŠ%«Y¨©q%jâd,Ôq`) ¤¦…šˆ ¦E>0Ùb²t–Ÿ  ÷jsςҒKÈcø(é›;k(’#ôŒQ ™C> õ³M9óºÆµ¤çâ;uÀ)5>RÔ¸fÓ~Ȧ—’-$fe«"FâUˆÊwµPÏu w+"åÉó¨6s™Û9(À¨ù©hE°½†n`m~“@©›p!Vkhµ Á1šbEqqÊ@ºèl›2 –Yã%‘‚hÛ{a¶‡ÅÞM²¬çL34®Çl]®‹ŽØŒm'RÜe35æöˆ­Á­ cP9šeÁköo´L³Ì=p8]”‡B¶,šº|ɏdzXˆØk*ÇÚ{#ñ‰pã(€¶‡9ý'šÜ³½¯kƒ†Â’ëSOƒ•Å®H6+a¢µˆ‹Y¨b˜b+XˆÖ!°u!¢"µˆˆn2ˆ Å0Ä`Å Ô®c(ÓÜGº•Ä»Œ âWî%q.áÐÄ÷î%umÍ£+ÜQ,Vn¦-GphU¸¢X­&,Gt ·K¢ÅÅ·¥RÄÊÉbKn N­R2g$VµÕó Qr#–ÓZUÏð0ÎtÙÀœz ëöo“Îk¯n„T°"SÞ+³/…€½"ižãO%Í%&Δâ‘ËØ´IˆÓ°Ë‰ÞM3.™yçÁzit›`4C`k¢¼á!álÄï sÂ[×!¤l¾æo"ƒIÔ'@ªu)3›ô®“@Z à¾] üœ'‡4¸PÞkÁ-qÄH‰ÓÍBd´ÿ —¹°ÄA&ÊUC„öz‚‚RæŠtf¬>˜ÑidšEçÑL÷áý¡V±h§­c¿¥¨ƒ@g¼…Ýö^ÞËc.ž„æ“I[ ª+·zÐÒÚ,½Ð»¶€C›7jk$๖€Ž¾ÅÙpp¶ÍþéΤ ½ØÎŒq ñpæžÅ¥#Øâ49ÃÂK^MYV“,¶Éz_òæ:…;Õ«¦I3âJ£¤û5$7Èxün\â]Êe¯(Ÿ&Ž‹¶2<6Ćf× æ¢ƱqWı[(ÙÂŽç‚T7¨@ÈÉÍß‚ïÙ"&3TYlGށ†)†#5ŠA©^T2ÆÁ†)©†©†¤yGXÁ†©"†)©¼ÅV WS†#©]R–r‹q5ÕbâWþBh¯u+ªÅÄ×ü„nÑ^êkªÁj‰jeœWˆÕÕ`µDµ2Ì+Ä µDµµ5Ô{¤Þ0RF’H÷AÛ<ÊÁ§ ƈæ0Ñ£ê4 öÚµ[¬/1²€â<-¬šö²r×0o×w ´xÐÒË„ g01¬„åEM蛇Ã\6µE›‘fÙO k÷CºnÓ1`iîÒ² áÂ!ÑLÄÿ ³¬\õ*:M=Ç»c‹2[‰ØsÕLò\ŒK L^™üÄN\¶#» Ç\……ßïIœÉ$¸ÎñÍ®ÔHÇ Ûí/´>Li”„†g^$ 7NÍÑÑ2M2ªNg=k½Ð}Ÿl6‡ —JWˆ”ÞéT·+µ¦üÂFè¢Vs6ýÆ4»2+2IÝ9ô9®ÇGÙÇ1+Ä8;*Õ§ž½D*îÑWÚçá3Ma¤·ˆ¥t}š²Ü…Q+Æüµ8HíS”üxGéÁˆ¦Ël„éÈ 5 µÄƒ6äÜ(kIš¯S†fÖ&¸®×v|Äyˆ*禌Éù@7-®Ä[]ÎÖ¿ê`º…=:…žJVnݳvðÖKE¼‚ »mà ÷f®:Ë ™–4rð¡4` ܹçž~‹C=œ…¾Ïj|VDtK.ƒ"9 Ï ­–éXá³6WÒïIL-Ї Ç db/install.php000064400000002131152266550060007314 0ustar00. /** * URL to link filter post install hook. * * @package filter_urltolink * @copyright 2020 Simey Lameze * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ defined('MOODLE_INTERNAL') || die(); function xmldb_filter_urltolink_install() { global $CFG; require_once($CFG->libdir . "/filterlib.php"); filter_set_global_state('urltolink', TEXTFILTER_ON, -1); } db/renamedclasses.php000064400000001777152266550060010656 0ustar00. /** * Renamed classes for the filter_urltolink plugin. * * @package filter_urltolink * @copyright Jun Pataleta * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ defined('MOODLE_INTERNAL') || die; $renamedclasses = [ 'filter_urltolink' => \filter_urltolink\text_filter::class, ]; lang/en/filter_urltolink.php000064400000002630152266550060012200 0ustar00. /** * Strings for filter_urltolink * * @package filter * @subpackage urltolink * @copyright 2010 David Mudrak * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ defined('MOODLE_INTERNAL') || die(); $string['embedimages'] = 'Embed images'; $string['embedimages_desc'] = 'Replace image urls with images in selected text formats.'; $string['filtername'] = 'Convert URLs into links and images'; $string['settingformats'] = 'Apply to formats'; $string['settingformats_desc'] = 'The filter will be applied only if the original text was inserted in one of the selected formats.'; $string['privacy:metadata'] = 'The Convert URLs into links and images plugin does not store any personal data.'; version.php000064400000002221152266550060006746 0ustar00. /** * Version details * * @package filter_urltolink * @copyright 2010 David Mudrak * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ defined('MOODLE_INTERNAL') || die(); $plugin->version = 2025041400; // The current plugin version (Date: YYYYMMDDXX). $plugin->requires = 2025040800; // Requires this Moodle version. $plugin->component = 'filter_urltolink'; // Full name of the plugin (used for diagnostics) filter.php000064400000002304152266550060006550 0ustar00. /** * File only retained to prevent fatal errors in code that tries to require/include this. * * @todo MDL-82708 delete this file as part of Moodle 6.0 development. * @deprecated This file is no longer required in Moodle 4.5+. * @package filter_urltolink * @copyright David Mudrak * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ defined('MOODLE_INTERNAL') || die(); debugging('This file is no longer required in Moodle 4.5+. Please do not include/require it.', DEBUG_DEVELOPER); classes/privacy/provider.php000064400000003006152266550060012227 0ustar00. /** * Privacy Subsystem implementation for filter_urltolink. * * @package filter_urltolink * @copyright 2018 Andrew Nicols * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ namespace filter_urltolink\privacy; defined('MOODLE_INTERNAL') || die(); /** * Privacy Subsystem for filter_urltolink implementing null_provider. * * @copyright 2018 Andrew Nicols * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class provider implements \core_privacy\local\metadata\null_provider { /** * Get the language string identifier with the component's language * file to explain why this plugin stores no data. * * @return string */ public static function get_reason(): string { return 'privacy:metadata'; } } classes/text_filter.php000064400000015635152266550060011264 0ustar00. namespace filter_urltolink; /** * Filter converting URLs in the text to HTML links * * @package filter_urltolink * @copyright 2010 David Mudrak * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class text_filter extends \core_filters\text_filter { /** * This might be eventually moved into parent class if we found it * useful for other filters, too. * * @var array global configuration for this filter */ protected static $globalconfig; #[\Override] public function filter($text, array $options = []) { if (!isset($options['originalformat'])) { // If the format is not specified, we are probably called by {@see format_string()} // in that case, it would be dangerous to replace URL with the link because it could // be stripped. therefore, we do nothing. return $text; } if (in_array($options['originalformat'], explode(',', get_config('filter_urltolink', 'formats')))) { $this->convert_urls_into_links($text); } return $text; } /** * Given some text this function converts any URLs it finds into HTML links * * @param string $text Passed in by reference. The string to be searched for urls. */ protected function convert_urls_into_links(&$text) { // I've added img tags to this list of tags to ignore. // See MDL-21168 for more info. A better way to ignore tags whether or not // they are escaped partially or completely would be desirable. For example: // // <a href="blah"> // <a href="blah">. $filterignoretagsopen = [']+?>', ']+?class="nolink"[^>]*?>']; $filterignoretagsclose = ['', '']; $ignoretags = []; filter_save_ignore_tags($text, $filterignoretagsopen, $filterignoretagsclose, $ignoretags); // Check if we support unicode modifiers in regular expressions. Cache it. // TODO: this check should be a environment requirement in Moodle 2.0, as far as unicode // chars are going to arrive to URLs officially really soon (2010?) // Original RFC regex from: http://www.bytemycode.com/snippets/snippet/796/ // Various ideas from: http://alanstorm.com/url_regex_explained // Unicode check, negative assertion and other bits from Moodle. static $unicoderegexp; if (!isset($unicoderegexp)) { $unicoderegexp = @preg_match('/\pL/u', 'a'); // This will fail silently, returning false. } // TODO MDL-21296 - use of unicode modifiers may cause a timeout. $urlstart = '(?:http(s)?://|(?]*>)/i', $text, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE); // Iterate through the tokenized text to handle chunks (html and content). foreach ($matches as $idx => $chunk) { // Nothing to do. We skip completely any html chunk. if (strpos(trim($chunk), '<') === 0) { continue; } // Nothing to do. We skip any content chunk having any of these attributes. if (preg_match('#(background=")|(action=")|(style="background)|(href=")|(src=")|(url [(])#', $chunk)) { continue; } // Arrived here, we want to process every word in this chunk. $text = $chunk; $words = explode(' ', $text); foreach ($words as $idx2 => $word) { // ReDoS protection. Stop processing if a word is too large. if (strlen($word) < 4096) { $words[$idx2] = preg_replace($regex, '$0', $word); } } $text = implode(' ', $words); // Copy the result back to the array. $matches[$idx] = $text; } $text = implode('', $matches); if (!empty($ignoretags)) { $ignoretags = array_reverse($ignoretags); // Reversed so "progressive" str_replace() will solve some nesting problems. $text = str_replace(array_keys($ignoretags), $ignoretags, $text); } if (get_config('filter_urltolink', 'embedimages')) { // Now try to inject the images, this code was originally in the mediapluing filter // this may be useful only if somebody relies on the fact the links in FORMAT_MOODLE get converted // to URLs which in turn change to real images. $search = '/([^>]*)<\/a>/is'; $text = preg_replace_callback($search, [self::class, 'get_image_markup'], $text); } } /** * Change links to images into embedded images. * * This plugin is intended for automatic conversion of image URLs when FORMAT_MOODLE used. * * @param array $link * @return string */ private function get_image_markup($link) { if ($link[1] !== $link[3]) { // This is not a link created by this filter, because the url does not match the text. return $link[0]; } return ''; } } tests/fixtures/sample.txt000064400000006223152266550060011613 0ustar00http://www.lipsum.com Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. Why do we use it?dummy It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like). Where does it come from? Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32. The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from "de Finibus Bonorum et Malorum" by Cicero are also reproduced in their exact original form, accompanied by English versions from the 1914 translation by H. Rackham. Where can I get some? There are many variations of passages of Lorem Ipsum available, but the majority have suffered alteration in some form, by injected humour, or randomised words which don't look even slightly believable. If you are going to use a passage of Lorem Ipsum, you need to be sure there isn't anything embarrassing hidden in the middle of text. All the Lorem Ipsum generators on the Internet tend to repeat predefined chunks as necessary, making this the first true generator on the Internet. It uses a dictionary of over 200 Latin words, combined with a handful of model sentence structures, to generate Lorem Ipsum which looks reasonable. The generated Lorem Ipsum is therefore always free from repetition, injected humour, or non-characteristic words etc. Wikipedia http://www.lorem-ipsum.info/ tests/text_filter_test.php000064400000047552152266550060012033 0ustar00. namespace filter_urltolink; /** * Unit test for the text_filter * * @package filter_urltolink * @category test * @copyright 2010 David Mudrak * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @covers \filter_urltolink\text_filter */ final class text_filter_test extends \basic_testcase { /** * Data provider for test_convert_urls_into_links. * * @return array */ public static function get_convert_urls_into_links_test_cases(): array { // Create a 4095 and 4096 long URLs. $superlong4095 = str_pad('http://www.superlong4095.com?this=something', 4095, 'a'); $superlong4096 = str_pad('http://www.superlong4096.com?this=something', 4096, 'a'); // phpcs:disable moodle.Files.LineLength.MaxExceeded, moodle.Files.LineLength.TooLong $texts = [ // Just a url. 'http://moodle.org - URL' => 'http://moodle.org - URL', 'www.moodle.org - URL' => 'www.moodle.org - URL', // Url with params. 'URL: http://moodle.org/s/i=1&j=2' => 'URL: http://moodle.org/s/i=1&j=2', // Url with escaped params. 'URL: www.moodle.org/s/i=1&j=2' => 'URL: www.moodle.org/s/i=1&j=2', // Https url with params. 'URL: https://moodle.org/s/i=1&j=2' => 'URL: https://moodle.org/s/i=1&j=2', // Url with port and params. 'URL: http://moodle.org:8080/s/i=1' => 'URL: http://moodle.org:8080/s/i=1', // URL with complex fragment. 'Most voted issues: https://tracker.moodle.org/browse/MDL#selectedTab=com.atlassian.jira.plugin.system.project%3Apopularissues-panel' => 'Most voted issues: https://tracker.moodle.org/browse/MDL#selectedTab=com.atlassian.jira.plugin.system.project%3Apopularissues-panel', // Domain with more parts. 'URL: www.bbc.co.uk.' => 'URL: www.bbc.co.uk.', // URL in brackets. '(http://moodle.org) - URL' => '(http://moodle.org) - URL', '(www.moodle.org) - URL' => '(www.moodle.org) - URL', // URL in brackets with a path. '(http://example.com/index.html) - URL' => '(http://example.com/index.html) - URL', '(www.example.com/index.html) - URL' => '(www.example.com/index.html) - URL', // URL in brackets with anchor. '(http://moodle.org/main#anchor) - URL' => '(http://moodle.org/main#anchor) - URL', '(www.moodle.org/main#anchor) - URL' => '(www.moodle.org/main#anchor) - URL', // URL in square brackets. '[http://moodle.org] - URL' => '[http://moodle.org] - URL', '[www.moodle.org] - URL' => '[www.moodle.org] - URL', // URL in square brackets with a path. '[http://example.com/index.html] - URL' => '[http://example.com/index.html] - URL', '[www.example.com/index.html] - URL' => '[www.example.com/index.html] - URL', // URL in square brackets with anchor. '[http://moodle.org/main#anchor] - URL' => '[http://moodle.org/main#anchor] - URL', '[www.moodle.org/main#anchor] - URL' => '[www.moodle.org/main#anchor] - URL', // Brackets within the url. 'URL: http://cc.org/url_(withpar)_go/?i=2' => 'URL: http://cc.org/url_(withpar)_go/?i=2', 'URL: www.cc.org/url_(withpar)_go/?i=2' => 'URL: www.cc.org/url_(withpar)_go/?i=2', 'URL: http://cc.org/url_(with)_(par)_go/?i=2' => 'URL: http://cc.org/url_(with)_(par)_go/?i=2', 'URL: www.cc.org/url_(with)_(par)_go/?i=2' => 'URL: www.cc.org/url_(with)_(par)_go/?i=2', 'http://en.wikipedia.org/wiki/%28#Parentheses_.28_.29 - URL' => 'http://en.wikipedia.org/wiki/%28#Parentheses_.28_.29 - URL', 'http://en.wikipedia.org/wiki/(#Parentheses_.28_.29 - URL' => 'http://en.wikipedia.org/wiki/(#Parentheses_.28_.29 - URL', // Escaped brackets in url. 'http://en.wikipedia.org/wiki/Slash_%28punctuation%29' => 'http://en.wikipedia.org/wiki/Slash_%28punctuation%29', // Anchor tag. 'URL: http://moodle.org' => 'URL: http://moodle.org', 'URL: www.moodle.org' => 'URL: www.moodle.org', 'URL: http://moodle.org' => 'URL: http://moodle.org', 'URL: www.moodle.org' => 'URL: www.moodle.org', // Trailing fullstop. 'URL: http://moodle.org/s/i=1&j=2.' => 'URL: http://moodle.org/s/i=1&j=2.', 'URL: www.moodle.org/s/i=1&j=2.' => 'URL: www.moodle.org/s/i=1&j=2.', // Trailing unmatched bracket. 'URL: http://moodle.org)
' => 'URL: http://moodle.org)
', // Partially escaped html. 'URL:

text www.moodle.org</p> text' => 'URL:

text www.moodle.org</p> text', // Decimal url parameter. 'URL: www.moodle.org?u=1.23' => 'URL: www.moodle.org?u=1.23', // Escaped space in url. 'URL: www.moodle.org?u=test+param&' => 'URL: www.moodle.org?u=test+param&', // Multiple urls. 'URL: http://moodle.org www.moodle.org' => 'URL: http://moodle.org www.moodle.org', // Containing anchor tags including a class parameter and a url to convert. 'URL: http://moodle.org www.moodle.org http://moodle.org' => 'URL: http://moodle.org www.moodle.org http://moodle.org', // Subdomain. 'http://subdomain.moodle.org - URL' => 'http://subdomain.moodle.org - URL', // Multiple subdomains. 'http://subdomain.subdomain.moodle.org - URL' => 'http://subdomain.subdomain.moodle.org - URL', // Looks almost like a link but isnt. 'This contains http, http:// and www but no actual links.' => 'This contains http, http:// and www but no actual links.', // No link at all. 'This is a story about moodle.coming to a cinema near you.' => 'This is a story about moodle.coming to a cinema near you.', // URLs containing utf 8 characters. 'http://Iñtërnâtiônàlizætiøn.com?ô=nëø' => 'http://Iñtërnâtiônàlizætiøn.com?ô=nëø', 'www.Iñtërnâtiônàlizætiøn.com?ô=nëø' => 'www.Iñtërnâtiônàlizætiøn.com?ô=nëø', // Text containing utf 8 characters outside of a url. 'Iñtërnâtiônàlizætiøn is important to http://moodle.org' => 'Iñtërnâtiônàlizætiøn is important to http://moodle.org', // Too hard to identify without additional regexs. 'moodle.org' => 'moodle.org', // Some text with no link between related html tags. 'no link here' => 'no link here', // Some text with a link between related html tags. 'a link here www.moodle.org' => 'a link here www.moodle.org', // Some text containing a link within unrelated tags. '
This is some text. www.moodle.com then some more text
' => '
This is some text. www.moodle.com then some more text
', // Check we aren't modifying img tags. 'image' => 'image', 'image' => 'image', 'image' => 'image', // And another url within one tag. ' ' => ' ', ' ' => ' ', '

' => '', '' => '', ' ' => ' ', // CSS URLs. '' => '
', '
' => '
', '
' => '
', '
' => '
', // Partially escaped img tag. 'partially escaped img tag <img src="http://moodle.org/logo/logo-240x60.gif" />' => 'partially escaped img tag <img src="http://moodle.org/logo/logo-240x60.gif" />', // Double http with www. 'One more link like http://www.moodle.org to test' => 'One more link like http://www.moodle.org to test', // Encoded URLs in the path. 'URL: http://127.0.0.1/one%28parenthesis%29/path?param=value' => 'URL: http://127.0.0.1/one%28parenthesis%29/path?param=value', 'URL: www.localhost.com/one%28parenthesis%29/path?param=value' => 'URL: www.localhost.com/one%28parenthesis%29/path?param=value', // Encoded URLs in the query. 'URL: http://127.0.0.1/path/to?param=value_with%28parenthesis%29¶m2=1' => 'URL: http://127.0.0.1/path/to?param=value_with%28parenthesis%29¶m2=1', 'URL: www.localhost.com/path/to?param=value_with%28parenthesis%29¶m2=1' => 'URL: www.localhost.com/path/to?param=value_with%28parenthesis%29¶m2=1', // Test URL less than 4096 characters in size is converted to link. 'URL: ' . $superlong4095 => 'URL: ' . $superlong4095 . '', // Test URL equal to or greater than 4096 characters in size is not converted to link. 'URL: ' . $superlong4096 => 'URL: ' . $superlong4096, // Testing URL within a span tag. 'URL: my link to http://google.com ' => 'URL: my link to http://google.com ', // Nested tags test. 'www.google.com' => 'www.google.com', // Test realistic content. '

Lorem ipsum amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut http://google.com aliquip ex ea commodo consequat. Duis aute irure in reprehenderit in excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia https://docs.google.com/document/d/BrokenLinkPleaseAyacDHc_Ov8aoskoSVQsfmLHP_jYAkRMk/edit?usp=sharing https://docs.google.com/document/d/BrokenLinkPleaseAyacDHc_Ov8aoskoSVQsfmLHP_jYAkRMk/edit?usp=sharing mollit anim id est laborum.

' => '

Lorem ipsum amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut http://google.com aliquip ex ea commodo consequat. Duis aute irure in reprehenderit in excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia https://docs.google.com/document/d/BrokenLinkPleaseAyacDHc_Ov8aoskoSVQsfmLHP_jYAkRMk/edit?usp=sharing https://docs.google.com/document/d/BrokenLinkPleaseAyacDHc_Ov8aoskoSVQsfmLHP_jYAkRMk/edit?usp=sharing mollit anim id est laborum.

', // Test some broken html. '5 < 10 www.google.com im a link' => '5 < 10 www.google.comim a link', 'h3 (www.styles.com/h3) < h1 (www.styles.com/h1)' => 'h3 (www.styles.com/h3) < h1 (www.styles.com/h1)', '

text www.moodle.org</p> text' => '

text www.moodle.org</p> text', // Some more urls. '' => '', 'www.google.com' => 'www.google.com' . '', 'http://nolandforzombies.com Zombies FTW http://aliens.org' => 'http://nolandforzombies.com Zombies FTW http://aliens.org', // Test 'nolink' class. 'URL: http://moodle.org' => 'URL: http://moodle.org', 'URL: http://moodle.org' => 'URL: http://moodle.org', ]; // phpcs:enable $data = []; foreach ($texts as $text => $correctresult) { $data[] = [$text, $correctresult]; } return $data; } /** * Test the convert_urls_into_links method. * * @dataProvider get_convert_urls_into_links_test_cases * @param string $text * @param string $correctresult */ public function test_convert_urls_into_links($text, $correctresult): void { $testablefilter = $this->get_testable_text_filter(); $testablefilter->convert_urls_into_links($text); $this->assertEquals($correctresult, $text); } /** * Get a copy of the filter configured for testing. * * @param array ...$args * @return \filter_urltolink\text_filter */ protected function get_testable_text_filter(...$args): text_filter { return new class extends text_filter { // phpcs:ignore moodle.Commenting.MissingDocblock.MissingTestcaseMethodDescription public function __construct() { } // phpcs:ignore moodle.Commenting.MissingDocblock.MissingTestcaseMethodDescription, Generic.CodeAnalysis.UselessOverridingMethod.Found public function convert_urls_into_links(&$text) { parent::convert_urls_into_links($text); } }; } } settings.php000064400000002704152266550060007127 0ustar00. /** * @package plugintype * @subpackage pluginname * @copyright 2010 David Mudrak * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ defined('MOODLE_INTERNAL') || die(); if ($ADMIN->fulltree) { $settings->add(new admin_setting_configmulticheckbox('filter_urltolink/formats', get_string('settingformats', 'filter_urltolink'), get_string('settingformats_desc', 'filter_urltolink'), [FORMAT_HTML => 1, FORMAT_MARKDOWN => 1, FORMAT_MOODLE => 1], format_text_menu())); $settings->add(new admin_setting_configcheckbox('filter_urltolink/embedimages', get_string('embedimages', 'filter_urltolink'), get_string('embedimages_desc', 'filter_urltolink'), 1)); }