-
Bug
-
Resolution: Fixed
-
Minor
-
2.2.4, 2.3.3
-
None
-
MOODLE_22_STABLE, MOODLE_23_STABLE
-
MOODLE_23_STABLE, MOODLE_24_STABLE
-
MDL-36808-master -
The activity completion toggle source code (./course/lib.php ~ line 1713) uses hardcoded HTML markup and single quotes to wrap tag attribute values. This will produce invalid markup when the resource/activity title contains single quotes. This malformed HTML breaks the layout in IE7 and IE8/9 running in compatibility mode.
The HTML that get produced >>
<form class='togglecompletion' method='post' action='http://test.dan.hi/course/togglecompletion.php'>
<div>
<input type='hidden' name='id' value='48' />
<input type='hidden' name='modulename' value='Google's Homepage' />
<input type='hidden' name='sesskey' value='WNC7Frlbip' />
<input type='hidden' name='completionstate' value='1' />
<input type='image' src='http://test.dan.hi/theme/image.php?theme=enterprise&image=i%2Fcompletion-manual-n&rev=392' alt='Not completed: Google's Homepage. Select to mark as complete.' title='Mark as complete: Google's Homepage' />
</div>
</form>
<< As shown the ALT and TITLE attribute values contain single quotes while being wrapped in single quotes.
Steps to Reproduce:
- Go to any course view page.
- Edit settings of the course and enable completion tracking and save.
- Turn editing on
- Add a URL (resource) a section (though any resource or activity will have the same effect).
- Give it the title > Google's Homepage
- Give it the URL value > http://www.google.com
- Click "Save and return to course"
- View HTML source generated for this feature
Suggested Solution
- Replace hardcode HTML markup with HTML generated by the html_writer:: functionality >>
echo html_writer::start_tag('form', array('class'=>'togglecompletion'.$extraclass, 'method'=>'post', 'action'=>$CFG->wwwroot.'/course/togglecompletion.php'));
echo html_writer::start_tag('div');
echo html_writer::empty_tag('input', array('type'=>'hidden', 'name'=>'id', 'value'=>$mod->id));
echo html_writer::empty_tag('input', array('type'=>'hidden', 'name'=>'modulename', 'value'=>s($mod->name)));
echo html_writer::empty_tag('input', array('type'=>'hidden', 'name'=>'sesskey', 'value'=>sesskey()));
echo html_writer::empty_tag('input', array('type'=>'hidden', 'name'=>'completionstate', 'value'=>$newstate));
echo html_writer::empty_tag('input', array('type'=>'image', 'src'=>$imgsrc, 'alt'=>$imgalt, 'title'=>$imgtitle));
echo html_writer::end_tag('div'); echo html_writer::end_tag('form');