62 Commits

Author SHA1 Message Date
Eloy Lafuente (stronk7)
1093256560
MDL-81522 phpunit: Add missing void return type to all tests
While this change is not 100% required now, it's good habit
and we are checking for it since Moodle 4.4.

All the changes in this commit have been applied automatically
using the moodle.PHPUnit.TestReturnType sniff and are, exclusively
adding the ": void" return types when missing.
2024-06-11 12:18:04 +02:00
Jun Pataleta
5289581d06
MDL-70829 core: Remove presentation role for decorative images
* An image with non-empty alt text should not have a presentation role.
* An empty alt attribute is sufficient for decorative images. No need to
add a presentation role for them.
* Additionally, if there is already text that is present for an image,
there's no need to add an alt text with the same text. Such images are
decorative and should just have an empty alt text.
2024-04-12 10:42:09 +08:00
Andrew Nicols
37ec9ee8ee
MDL-80072 core: Move format_string to core\formatting 2024-02-12 11:11:16 +08:00
Jun Pataleta
030def7a46
Merge branch 'MDL-80079-master' of https://github.com/andrewnicols/moodle 2023-12-06 21:59:47 +08:00
Paul Holden
4be39296d6
MDL-80185 lang: use iso6391 language code for HTML lang attributes.
This resolves accessibility issues where Moodle language pack codes
didn't always map to correspondingly named iso6391 codes.

Where this value is defined in the language configuration, it will
now be used.
2023-11-21 21:37:12 +00:00
Andrew Nicols
dab4a2b66f
MDL-80079 core: Correct incorrect arg to format_string::$options 2023-11-14 22:28:55 +08:00
Petr Skoda
989636b0de MDL-78505 core: stop mangling existing Mardown in text editors
The problem is that HTML Purifier is not compatible with Markdown,
that means we cannot sanitise Markdown texts before editing.

Luckily Markdown has to use plain text editor which does not have
XSS problems.

The only tiny downside is that Markdown cannot be allowed
in "trust text" areas any more.
2023-08-15 14:26:59 +02:00
Andrew Nicols
f58a71baab MDL-77308 core: Remove editor_tiny from core 2023-03-09 15:28:35 +08:00
Meirza
e2cd808b34 MDL-76415 core: Fixed ${var} string interpolation deprecations.
Since PHP 8.2, placing the dollar sign outside the curly brace is deprecated when
the expression inside the braces resolves to a variable or an expression.
2023-02-13 19:51:46 +07:00
Andrew Nicols
19bedb8eba MDL-76362 core: Short-circuit strip_querystring on empty values 2023-01-23 09:15:55 +08:00
Matteo Scaramuccia
71883c2add MDL-72461 core: Required JS files in $PAGE served by the Moodle handler 2022-12-09 13:47:19 +01:00
Jun Pataleta
5bc72f5176 Merge branch 'MDL-76559-master' of https://github.com/andrewnicols/moodle 2022-12-06 23:19:53 +08:00
Andrew Nicols
f375cac31a MDL-76559 core: validate_email should not accept empty values 2022-12-06 20:53:30 +08:00
Marina Glancy
e5f862d0b1 MDL-76493 core: make sure format_string(null) works on PHP 8.1 2022-11-26 14:02:32 +01:00
Jun Pataleta
92e080465e MDL-72885 core: New weblib function get_html_lang_attribute_value()
Converts a language code to hyphen-separated format in accordance to the
BCP47 syntax appropriate for the HTML lang attribute.

See
https://datatracker.ietf.org/doc/html/rfc5646#section-2.1
https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/lang
2022-05-27 19:38:54 +08:00
Andrew Nicols
a7f6c8cdcd MDL-72701 core: Improve code coverage for core 2021-12-21 09:24:00 +08:00
Sara Arjona
32576936ad MDL-72347 filter: Remove censor filter
Word censorship filter is not widely used these days so it has been
removed from Moodle core.
2021-10-04 09:28:59 +02:00
Eloy Lafuente (stronk7)
ba5b6089d5 MDL-71036 phpunit: Renamed various regexp-related assertions
In PHPUnit 9.1, the following regexp-related assertions
have been deprecated and there are new alternatives for
all them:
    - assertRegExp()     -> assertMatchesRegularExpression()
    - assertNotRegExp()  -> assertDoesNotMatchRegularExpression()

This is about to, simply, move all cases to the new alternatives.

Source: https://github.com/sebastianbergmann/phpunit/blob/9.1.0/ChangeLog-9.1.md

Regexp to find all them:

    ag 'assertRegExp|assertNotRegExp' -li
2021-03-11 19:22:24 +01:00
Bas Brands
4394f9e358 MDL-67735 theme_boost: remove bs2 and bs4alpha compatibility css 2020-08-17 08:16:42 +00:00
Paul Holden
eb9f830604 MDL-66762 user: stricter email validation. 2019-11-07 09:00:19 +08:00
[Peter Burnett]
d82b6004bf MDL-66280 core: Added unit tests for print_password_policy 2019-08-02 11:34:23 +10:00
Arjen Lentz
4b71e99564 MDL-21475 weblib: Simplify validate_email() to use existing function. 2019-02-19 10:51:21 +10:00
Andrew Nicols
8af75f08e8 MDL-36754 tests: Move moodle_url tests to own file 2018-08-14 07:06:09 +08:00
Jun Pataleta
c353ad20c3 MDL-45170 core: Integration review fixes
* Pass $forcehttps parameter to call extract_draft_file_urls_from_text()
 call in \core_weblib_testcase::test_extract_draft_file_urls_from_text()
* Style fixes
2018-08-08 16:17:32 +08:00
Charles Fulton
7d7d3b1731 MDL-45170 files: check other draftfile areas when processing 2018-08-08 16:15:23 +08:00
Ryan Wyllie
748545858c MDL-60942 filters: include filter in format_string cache key 2017-12-01 06:49:24 +00:00
Matteo Scaramuccia
cdf8238b14 MDL-57379 Files: Improved file argument evaluation.
get_file_argument() is responsible to extract the relative path
of the file to be served by a specific Moodle component
like a theme or a module.
Some modules like scorm and imscp require slasharguments support
and they force it when creating the URLs to serve their files.
It should honor the slasharguments setting but this could break
those instances where existing hard-coded links still make usage of
the "old" format, the one when slasharguments is set to No i.e. '?file='.

Its logic has been improved by looking at when the URL is related to
serving a plug-in file in a "forced" slasharguments way of serving it
i.e. using '/pluginfile.php/' and not '/pluginfile.php?'.
2017-02-19 16:39:04 +01:00
David Mudrák
7620746f67 MDL-57531 mail: Make validate_email return actual boolean as expected
It was discovered by unit tests that the return value is not a real
boolean as was intuitively expected and documented. To avoid potential
issues with the truthyness in the future, we explicitly cast the return
value to boolean now.
2017-01-04 13:16:07 +01:00
David Mudrák
61367eb639 MDL-57531 mail: Validate the sender's email address
The patch adds validation for the noreplyaddress setting variable, for
the explicit $replyto parameter and for the sender's email. In case of
misconfigured noreplyaddress setting, it falls back to the default
noreply address value. In case of invalid email in the user's record,
the email is not sent.

The patch also adds unit test for the value returned by the function
generate_email_processing_address() so that it can be considered as a
valid email, too.

This is supposed to significantly minimise the risk of exploiting the
vulnerability in PHPMailer's Sender field.
2017-01-04 12:35:19 +01:00
sam marshall
b16b1f86b1 MDL-55650 Library: s() function - tweak parameters for performance
The s() function includes a comment saying that parameter options
should be modified to improve performance once PHP 5.4 is required.
Since Moodle has required PHP 5.4 for some time, we should probably
make the change and remove the comment.

According to my benchmarking, these changes make s() about 7% faster
and will save a staggering 2ms from a typical course view that calls
it 8,000 times.
2016-08-22 15:38:13 +01:00
Rajesh Taneja
52f3e060e4
MDL-55091 phpunit: Following has been deprecated.
1. getMock()
2. setExpectedException()
3. checkForUnintentionallyCoveredCode renamed to beStrictAboutCoversAnnotation
4. beStrictAboutTestSize renamed to enforceTimeLimit
5. UnitTestCase class is now fully removed.
2016-07-26 10:11:30 +08:00
Cameron Ball
6fb1a7177f
MDL-47371 weblib: Add option to disable escaping 2016-07-12 10:31:17 +08:00
David Monllao
505ce88467 MDL-54627 search: Ensure that all format_string strings are text.
All user input that is usually displayed through format_strings with
filters like mulitlang applied should be converted to text as well.
2016-05-19 13:16:01 +08:00
Cameron Ball
3e3f624549 MDL-53393 libraries: Upgrade Html2Text to 4.0.1 2016-03-21 12:05:33 +08:00
Brendan Heywood
462065e822 MDL-51718 weblib: Allow moodle_url scheme to be set 2015-11-05 09:08:00 +11:00
Andrew Nicols
44250050dc MDL-51524 tests: Fix broken tests
The upgraded version of HTML2Text highlighted some bugs in our unit tests.

In the IOS test, the HTML content includes a couple of patches of  
In the previous version of HTML2Text, these were being converted to
breaking spaces. In one of these cases, it was then removed due to a trim.
The expected texts have been converted to use the correct non-breaking spaces.
In the case of the trimmed one, it is no longer trimmed as non-breaking
spaces are not trimmed.
This gives a truer reflection of the actual text.

In the case of the Outlook test, this trailing whitespace is not present in
the source. It was likely caused by a bug in the previous version of
HTML2Text.

In the case of the weblib change, the test was just wrong. Both of the
actual characters are encodings for an HTML bullet (decimal and hex) and
should both be converted to the relevant UTF8 representation of this
bullet.
2015-10-12 09:35:59 +08:00
Jetha Chan
b42cb67935 MDL-50868 weblib: add unit test for ruby support 2015-07-24 14:09:48 +09:00
Sam Hemelryk
9915109268 MDL-48304 moodle_url: compare now considers anchor 2014-11-20 15:38:34 +13:00
Tim Hunt
1fa2823de8 MDL-46688 weblib: improve the highlight function.
Thanks to Joseph Baxter for suggesting some of the test cases.
2014-08-08 17:51:58 +01:00
Frederic Massart
0a8b3583ca MDL-42995 libraries: Global function to strip pluginfile content 2014-01-06 09:29:25 +01:00
Petr Škoda
a9d2f1b414 MDL-41707 allow custom location of external test files used from unit tests 2013-09-27 10:47:56 +02:00
Simon Coggins
d06ffbdf2d MDL-41806 Add assessors to moodle_url class
New assessors for scheme, host and port.
2013-09-16 16:14:29 +12:00
Petr Škoda
037d673ea9 MDL-39474 add set_debugging() tests 2013-08-21 15:41:35 +02:00
Petr Škoda
b33bf039f3 MDL-39915 cleanup core_weblib_testcase 2013-07-28 15:06:23 +02:00
Sam Hemelryk
61b223a632 MDL-40635 moodle_url: can now set anchor during construction 2013-07-15 10:17:49 +12:00
Petr Škoda
66056f994f MDL-39096 fix obfuscate_text() utf-8 compatibility 2013-06-07 22:38:48 +02:00
Eloy Lafuente (stronk7)
bee592add8 Merge branch 'wip-MDL-39216-m25' of git://github.com/samhemelryk/moodle 2013-05-01 02:29:36 +02:00
Sam Hemelryk
a697000b53 MDL-39216 url: included test for empty string param 2013-05-01 12:27:36 +12:00
Sam Hemelryk
45d9752205 MDL-39216 url: updated tests to show desired outcome 2013-04-30 11:09:47 +12:00
Sam Hemelryk
616396a6cf MDL-39216 url: new moodle_url tests for valueless params 2013-04-30 11:09:47 +12:00