Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions classes/pluginbase/dataformfieldrenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -259,11 +259,11 @@ public function parse_template(&$mform, $definitions) {
$field = $this->_field;
$patterns = array_keys($definitions);

foreach($patterns as &$pattern) {
$pattern = preg_quote($pattern, '/');
}
$delims = implode('|', $patterns);

// Escape [ and ] and the pattern rule character *.
$delims = quotemeta($delims);

$parts = preg_split("/($delims)/", $field->label, null, PREG_SPLIT_DELIM_CAPTURE);
$htmlparts = '';
foreach ($parts as $part) {
Expand Down
8 changes: 5 additions & 3 deletions classes/pluginbase/dataformview.php
Original file line number Diff line number Diff line change
Expand Up @@ -1071,9 +1071,11 @@ protected function get_field_definitions($entry, $options) {
* @param array $patterns array of arrays of pattern replacement pairs
*/
protected function split_tags($patterns, $subject) {
foreach($patterns as &$pattern) {
$pattern = preg_quote($pattern, '/');
}

$delims = implode('|', $patterns);
// Escape [ and ] and the pattern rule character *.
$delims = quotemeta($delims);

$elements = preg_split("/($delims)/", $subject, null, PREG_SPLIT_DELIM_CAPTURE);

Expand Down Expand Up @@ -1219,7 +1221,7 @@ public function get_entries_display(array $options = null) {
$pluginfileurl = isset($options['pluginfileurl']) ? $options['pluginfileurl'] : null;
if ($pluginfileurl) {
$pluginfilepath = \moodle_url::make_file_url("/pluginfile.php", "/{$this->df->context->id}/mod_dataform/content");
$pattern = str_replace('/', '\/', $pluginfilepath);
$pattern = preg_quote($pluginfilepath, '/');
$pattern = "/$pattern\/\d+\//";
$html = preg_replace($pattern, $pluginfileurl, $html);
}
Expand Down