Need a Mustache helper method for html entities
Description
Testing Instructions
Setup
Log in as admin
Go to Site administration > Plugins > Enrolments > Manage enrol plugins
Enable "Publish as LTI tool"
Go to Site administration > Language > Language customisation
Select English
Click on the 'Import custom strings' button
Click on the 'Continue' button after the language pack is loaded by Moodle
Upload the file
into the upload area
Set 'Import mode' on 'Create or update all strings from the component(s)'
Click on the 'Import file' button
Click on 'Continue'
Click on the 'Save strings to language pack' button
Click on the 'Continue' button
Create a new course (do NOT enrol anyone into the course)
Enter the course
Test 1
Log in as admin
Go to Site administration > Users > Privacy and policies > Policy settings
Set 'Site policy handler' to 'Policies (tool_policy)' and save changes
Go to Site administration > Users > Privacy and policies > Manage policies
Click on the 'New policy' button
Create a new policy with the following values
Name: my policy
Summary: my summary
Full policy: my full policy
Show policy before showing other policies: No
Agreement optional: No
Policy status: Active
Log out
Go to the signup page
Click on the N"e>x button
Verify that you see 2 buttons with these exact titles:
N"e>x<t
C"<an>c"el
Test 2
Log in as admin
Enable the 'Publish as LTI tool' enrolment plugin on your site.
Visit a course
Go to Course administration > Published as LTI tools
View page source (usually Ctrl+u)
Copy the source
Set the check by field to 'text input' and replace the content of the text editor with what you copied on step 7
Press the 'check' button
Press the 'message filtering' button
Verify that you don't see any errors
Note: because of some recently integrated codes, you may see some irrelevant errors. Here is a list of errors that you can ignore, but there can be more. Please check with me if you see any error that is not listed here before failing this issue:Bad value “#” for attribute “type” on element “button”
Duplicate ID “moremenu-dropdown[some-number]”
Attribute aria-expanded not allowed on element a at this point.
Test 3
Log in as admin
Go to the 'Site home' page
Click on the cog icon at the top right of the page and then click on 'More...'
Go to Question bank > Questions
Verify that there is a dropdown menu with the following placeholder text
Fil<t"er "by' t>ags...
Click on the 'Create a new question...' button
Verify that the opened dialogue has a button with this exact text
C"<an>c"el
Create a true/false question
After creating the question, click on the 'Edit' link next to the question
Verify that the menu has an item with this exact text
It's the "Preview" button
Test 4
Log in as admin
Go into a course
From the navigation drawer, click on 'Grades'
Go to the Setup tab
Verify that you see a button with this exact title
S"a>v<e ch"an'ges
Test 5
Log in as admin
Go to calendar
Click on the 'New event' button
Enable your screen reader
Press Tab multiple times until the close button (the X button) is focused
Verify that the screen reader says the following:
It's a "close" button
Test 6
Log in as admin
Enable 'OAuth 2' authentication in site administration > plugins > authentication > manage authentication
Go to site administration > server > OAuth 2 services
Click on the 'Google' button
Set the 'Name displayed on the login page' field to the following and then click on the 'Save changes' button
H"e>llo
Log out
Go to the login page
Verify that the placeholder on the username and password fields says
It's the "Username" field
It's the "password" field
Verify that you see a button with the exact label as the following
H"e>llo
Put your mouse over the button
Verify that the tooltip you see has the exact same text as the button's text (311 only)
Test 7
Open theme/boost/settings.php and edit the line that contains admin_setting_configcolourpicker to this
$setting = new admin_setting_configcolourpicker($name, $title, $description, '', ['selector'=>'.some .css .selector']);
Log in as admin
Go to Site administration > Appearance > Themes > Boost
Verify the button next to the colour picker element has the following label
It's the "Preview" button
Test 8
Log in as admin
Create a course
Create 2 pages in the course with the following names (use the same for page content).
It's a page
It's another "page" with > special < characters
Enter the first page
View page source (usually Ctrl+u)
Copy the source
Set the check by field to 'text input' and replace the content of the text editor with what you copied on step 6
Press the 'check' button
Press the 'message filtering' button
Verify that you don't see any errors
Note: because of some recently integrated codes, you may see some irrelevant errors. Here is a list of errors that you can ignore, but there can be more. Please check with me if you see any error that is not listed here before failing this issue:Bad value “#” for attribute “type” on element “button”
Duplicate ID “moremenu-dropdown[some-number]”
Attribute aria-expanded not allowed on element a at this point.
Test 9
Open the file course/classes/management_renderer.php and in the function category_listitem_actions, modify
array('data-action' => $key, 'class' => 'action-'.$key)
toarray('data-action' => $key, 'class' => 'action-'.$key, 'title' => $action['string'])
Log in as admin
Go to the course management page (Site administration > Courses > Manage courses and categories).
Click on the gear icon of the 'Miscellaneous' category
Hover your mouse over the create a new subcategory option
Verify that the tooltip text is exactly the same as the text of the menu item
Test 10
Log in as admin
Go into a course
Create an assignment with the following values
Assignment name: It's an "assignment" with >special< chars
Completion tracking: Students can manually mark the activity as completed
Expect completed on: set it to sometime in tomorrow's date
Enrol yourself into the course
Go to dashboard
Set the filter of the timeline block to show overdue events
Set the filter of the timeline block to show all events
Verify that you see the assignment is listed on the timeline block
Hover your mouse over the title of the assignment
Verify that you see a tooltip with the following text (because of a known issue, you'd see html entities instead of > and <)
It's an "assignment" with >special< chars should be completed
Automated test results
Pre-check results
Workaround
Attachments
Activity
Thanks for your contributions! This change is now available from the main moodle.git repository and will shortly be available on download.moodle.org.
Closing as fixed!
Confirmed and verified in master and 311.
Test Passed
Hi Shamim,
Thank you for working on this issue and fixing the missing points
A. I added unit tests to cover the mustache_clean_string_helper.strs method
B. Added the comment in lib/upgrade.txt
C. As per our discussion, I renamed the helper to cleanstr
D. I deleted the 310 code. and provided an updated patch for 311.
E. The master branch is still not rebased to the latest version (it's based on '2021102900.03'). The 3.11 branch had also some conflicts with the same file (but in that case it was based on a more recent version). I've resolved these conflicts with lib/upgrade.txt in the merge commit for both branches.
F. Thanks for the explanation related to the last commit! It makes sense! Feel free to link these other issues here (to give more context and help to identify them).
It has now been integrated to 3.11 and master \o/
Over to testing.
Fails against automated checks.
Checked https://moodle.atlassian.net/browse/MDL-70721#icft=MDL-70721 using repository: git://github.com/rezaies/moodle.git
MOODLE_311_STABLE [branch: MDL-70721-311 | CI Job]
Warn: the remote 'git://github.com/rezaies/moodle.git' is using an unauthenticated github url which is no longer supported. Converting to 'https://github.com/rezaies/moodle.git'
Error: The MDL-70721-311 branch at https://github.com/rezaies/moodle.git does not apply clean to origin/MOODLE_311_STABLE
master [branch: MDL-70721-master | CI Job]
Warn: the remote 'git://github.com/rezaies/moodle.git' is using an unauthenticated github url which is no longer supported. Converting to 'https://github.com/rezaies/moodle.git'
Error: The MDL-70721-master branch at https://github.com/rezaies/moodle.git does not apply clean to origin/master
Hi Sara,
Thank you for reviewing the code.
A. I added unit tests to cover that method
B. Added the comment there
C. As per our discussion, I renamed the helper to cleanstr
D. I deleted the 310 code. and provided an updated patch for 311.
E. Rebased
F. I added that because without that my testing instructions were failing. Almost any page that I picked to use in my testing instructions were having many HTML validation failures. So I had to fix one and leave the others to other issues as you suggested. but I just had to make sure that I can use some pages in my testing instruction. The particular issue in the dashboard page was that there were js exceptions on the timeline block in dashboard (because of all the special characters I used in testing instructions). To fix the issue, I removed the title attribute (because it was redundant as described in the commit message) instead of using cleanstr there.
Details
Details
Priority
Components
Assignee
Reporter
Peer reviewer
Integrator
Fix versions
Tester
Participants
Pull from Repository
Pull Main Diff URL
Pull Main Branch
Clockify
Start / Stop
Clockify

The quote helper method is not always useful in some cases. The #quote helper is used when we want to avoid the situations where double quotes can break the JSON syntax. So in order to escape the double quotes we use the #quote helper. But that's only useful in JSON or Javascript. The reason is that the #quote helper escapes double quotes with a backslash. Whereas in HTML, we don't escape with a backslash. we need to replace double quotes with its HTML entity instead.
Then we can use the new helper when we are working with attributes such as aria-label