Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
integration
prechecker
Commits
ce878562
Commit
ce878562
authored
Mar 02, 2016
by
Eloy Lafuente
Browse files
Merge branch 'MDL-52136-master' of
git://github.com/andrewnicols/moodle
parents
cc32a710
e5a1f7d9
Changes
12
Hide whitespace changes
Inline
Side-by-side
lib/amd/src/templates.js
View file @
ce878562
...
@@ -222,6 +222,27 @@ define([ 'core/mustache',
...
@@ -222,6 +222,27 @@ define([ 'core/mustache',
return
'
{{_s
'
+
index
+
'
}}
'
;
return
'
{{_s
'
+
index
+
'
}}
'
;
};
};
/**
* Quote helper used to wrap content in quotes, and escape all quotes present in the content.
*
* @method quoteHelper
* @private
* @param {string} sectionText The text to parse the arguments from.
* @param {function} helper Used to render subsections of the text.
* @return {string}
*/
var
quoteHelper
=
function
(
sectionText
,
helper
)
{
var
content
=
helper
(
sectionText
.
trim
(),
this
);
// Escape the {{ and the ".
// This involves wrapping {{, and }} in change delimeter tags.
content
=
content
.
replace
(
'
"
'
,
'
\\
"
'
)
.
replace
(
/
([\{\}]{2,3})
/g
,
'
{{=<% %>=}}$1<%={{ }}=%>
'
)
;
return
'
"
'
+
content
+
'
"
'
;
};
/**
/**
* Add some common helper functions to all context objects passed to templates.
* Add some common helper functions to all context objects passed to templates.
* These helpers match exactly the helpers available in php.
* These helpers match exactly the helpers available in php.
...
@@ -239,6 +260,7 @@ define([ 'core/mustache',
...
@@ -239,6 +260,7 @@ define([ 'core/mustache',
context
.
str
=
function
()
{
return
stringHelper
;
};
context
.
str
=
function
()
{
return
stringHelper
;
};
context
.
pix
=
function
()
{
return
pixHelper
;
};
context
.
pix
=
function
()
{
return
pixHelper
;
};
context
.
js
=
function
()
{
return
jsHelper
;
};
context
.
js
=
function
()
{
return
jsHelper
;
};
context
.
quote
=
function
()
{
return
quoteHelper
;
};
context
.
globals
=
{
config
:
config
};
context
.
globals
=
{
config
:
config
};
context
.
currentTheme
=
themeName
;
context
.
currentTheme
=
themeName
;
};
};
...
...
lib/classes/output/mustache_quote_helper.php
0 → 100644
View file @
ce878562
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Wrap content in quotes, and escape all quotes used.
*
* @package core
* @category output
* @copyright 2016 Andrew Nicols <andrew@nicols.co.uk>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace
core\output
;
/**
* Wrap content in quotes, and escape all quotes used.
*
* @copyright 2016 Andrew Nicols <andrew@nicols.co.uk>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class
mustache_quote_helper
{
/**
* Wrap content in quotes, and escape all quotes used.
*
* Note: This helper is only compatible with the standard {{ }} delimeters.
*
* @param string $text The text to parse for arguments.
* @param Mustache_LambdaHelper $helper Used to render nested mustache variables.
* @return string
*/
public
function
quote
(
$text
,
\
Mustache_LambdaHelper
$helper
)
{
// Split the text into an array of variables.
$content
=
trim
(
$text
);
$content
=
$helper
->
render
(
$content
);
// Escape the {{ and the ".
$content
=
str_replace
(
'"'
,
'\\"'
,
$content
);
$content
=
preg_replace
(
'([{}]{2,3})'
,
'{{=<% %>=}}${0}<%={{ }}=%>'
,
$content
);
return
'"'
.
$content
.
'"'
;
}
}
lib/classes/output/mustache_string_helper.php
View file @
ce878562
...
@@ -76,4 +76,3 @@ class mustache_string_helper {
...
@@ -76,4 +76,3 @@ class mustache_string_helper {
return
get_string
(
$key
,
$component
,
$a
);
return
get_string
(
$key
,
$component
,
$a
);
}
}
}
}
lib/outputrenderers.php
View file @
ce878562
...
@@ -91,6 +91,7 @@ class renderer_base {
...
@@ -91,6 +91,7 @@ class renderer_base {
$loader
=
new
\
core\output\mustache_filesystem_loader
();
$loader
=
new
\
core\output\mustache_filesystem_loader
();
$stringhelper
=
new
\
core\output\mustache_string_helper
();
$stringhelper
=
new
\
core\output\mustache_string_helper
();
$quotehelper
=
new
\
core\output\mustache_quote_helper
();
$jshelper
=
new
\
core\output\mustache_javascript_helper
(
$this
->
page
->
requires
);
$jshelper
=
new
\
core\output\mustache_javascript_helper
(
$this
->
page
->
requires
);
$pixhelper
=
new
\
core\output\mustache_pix_helper
(
$this
);
$pixhelper
=
new
\
core\output\mustache_pix_helper
(
$this
);
...
@@ -99,6 +100,7 @@ class renderer_base {
...
@@ -99,6 +100,7 @@ class renderer_base {
$helpers
=
array
(
'config'
=>
$safeconfig
,
$helpers
=
array
(
'config'
=>
$safeconfig
,
'str'
=>
array
(
$stringhelper
,
'str'
),
'str'
=>
array
(
$stringhelper
,
'str'
),
'quote'
=>
array
(
$quotehelper
,
'quote'
),
'js'
=>
array
(
$jshelper
,
'help'
),
'js'
=>
array
(
$jshelper
,
'help'
),
'pix'
=>
array
(
$pixhelper
,
'pix'
));
'pix'
=>
array
(
$pixhelper
,
'pix'
));
...
...
mod/forum/classes/output/forum_post.php
View file @
ce878562
...
@@ -34,7 +34,7 @@ defined('MOODLE_INTERNAL') || die();
...
@@ -34,7 +34,7 @@ defined('MOODLE_INTERNAL') || die();
*
*
* @property boolean $viewfullnames Whether to override fullname()
* @property boolean $viewfullnames Whether to override fullname()
*/
*/
class
forum_post
implements
\
renderable
{
class
forum_post
implements
\
renderable
,
\
templatable
{
/**
/**
* The course that the forum post is in.
* The course that the forum post is in.
...
@@ -134,9 +134,65 @@ class forum_post implements \renderable {
...
@@ -134,9 +134,65 @@ class forum_post implements \renderable {
* Export this data so it can be used as the context for a mustache template.
* Export this data so it can be used as the context for a mustache template.
*
*
* @param \mod_forum_renderer $renderer The render to be used for formatting the message and attachments
* @param \mod_forum_renderer $renderer The render to be used for formatting the message and attachments
* @param bool $plaintext Whethe the target is a plaintext target
* @return stdClass Data ready for use in a mustache template
* @return stdClass Data ready for use in a mustache template
*/
*/
public
function
export_for_template
(
\
mod_forum_renderer
$renderer
)
{
public
function
export_for_template
(
\
renderer_base
$renderer
,
$plaintext
=
false
)
{
if
(
$plaintext
)
{
return
$this
->
export_for_template_text
(
$renderer
);
}
else
{
return
$this
->
export_for_template_html
(
$renderer
);
}
}
/**
* Export this data so it can be used as the context for a mustache template.
*
* @param \mod_forum_renderer $renderer The render to be used for formatting the message and attachments
* @return stdClass Data ready for use in a mustache template
*/
protected
function
export_for_template_text
(
\
mod_forum_renderer
$renderer
)
{
return
array
(
'id'
=>
html_entity_decode
(
$this
->
post
->
id
),
'coursename'
=>
html_entity_decode
(
$this
->
get_coursename
()),
'courselink'
=>
html_entity_decode
(
$this
->
get_courselink
()),
'forumname'
=>
html_entity_decode
(
$this
->
get_forumname
()),
'showdiscussionname'
=>
html_entity_decode
(
$this
->
get_showdiscussionname
()),
'discussionname'
=>
html_entity_decode
(
$this
->
get_discussionname
()),
'subject'
=>
html_entity_decode
(
$this
->
get_subject
()),
'authorfullname'
=>
html_entity_decode
(
$this
->
get_author_fullname
()),
'postdate'
=>
html_entity_decode
(
$this
->
get_postdate
()),
// Format some components according to the renderer.
'message'
=>
html_entity_decode
(
$renderer
->
format_message_text
(
$this
->
cm
,
$this
->
post
)),
'attachments'
=>
html_entity_decode
(
$renderer
->
format_message_attachments
(
$this
->
cm
,
$this
->
post
)),
'canreply'
=>
$this
->
canreply
,
'permalink'
=>
$this
->
get_permalink
(),
'firstpost'
=>
$this
->
get_is_firstpost
(),
'replylink'
=>
$this
->
get_replylink
(),
'unsubscribediscussionlink'
=>
$this
->
get_unsubscribediscussionlink
(),
'unsubscribeforumlink'
=>
$this
->
get_unsubscribeforumlink
(),
'parentpostlink'
=>
$this
->
get_parentpostlink
(),
'forumindexlink'
=>
$this
->
get_forumindexlink
(),
'forumviewlink'
=>
$this
->
get_forumviewlink
(),
'discussionlink'
=>
$this
->
get_discussionlink
(),
'authorlink'
=>
$this
->
get_authorlink
(),
'authorpicture'
=>
$this
->
get_author_picture
(),
'grouppicture'
=>
$this
->
get_group_picture
(),
);
}
/**
* Export this data so it can be used as the context for a mustache template.
*
* @param \mod_forum_renderer $renderer The render to be used for formatting the message and attachments
* @return stdClass Data ready for use in a mustache template
*/
protected
function
export_for_template_html
(
\
mod_forum_renderer
$renderer
)
{
return
array
(
return
array
(
'id'
=>
$this
->
post
->
id
,
'id'
=>
$this
->
post
->
id
,
'coursename'
=>
$this
->
get_coursename
(),
'coursename'
=>
$this
->
get_coursename
(),
...
...
mod/forum/renderer.php
View file @
ce878562
...
@@ -191,7 +191,7 @@ class mod_forum_renderer extends plugin_renderer_base {
...
@@ -191,7 +191,7 @@ class mod_forum_renderer extends plugin_renderer_base {
* @return string
* @return string
*/
*/
public
function
render_forum_post_email
(
\
mod_forum\output\forum_post_email
$post
)
{
public
function
render_forum_post_email
(
\
mod_forum\output\forum_post_email
$post
)
{
$data
=
$post
->
export_for_template
(
$this
);
$data
=
$post
->
export_for_template
(
$this
,
$this
->
target
===
RENDERER_TARGET_TEXTEMAIL
);
return
$this
->
render_from_template
(
'mod_forum/'
.
$this
->
forum_post_template
(),
$data
);
return
$this
->
render_from_template
(
'mod_forum/'
.
$this
->
forum_post_template
(),
$data
);
}
}
...
...
mod/forum/templates/forum_post_email_htmlemail_body.mustache
View file @
ce878562
...
@@ -87,7 +87,10 @@
...
@@ -87,7 +87,10 @@
{{{
subject
}}}
{{{
subject
}}}
</div>
</div>
<div
class=
"author"
>
<div
class=
"author"
>
{{#
str
}}
bynameondate, forum, { "name": "
<a
target=
'_blank'
href=
'
{{{
authorlink
}}}
'
>
{{
authorfullname
}}
</a>
", "date": "
{{
postdate
}}
" }
{{/
str
}}
{{#
str
}}
bynameondate, forum, {
"name":
{{#
quote
}}
<a
target=
'_blank'
href=
'
{{{
authorlink
}}}
'
>
{{
authorfullname
}}
</a>
{{/
quote
}}
,
"date":
{{#
quote
}}{{
postdate
}}{{/
quote
}}
}
{{/
str
}}
</div>
</div>
</td>
</td>
</tr>
</tr>
...
...
mod/forum/templates/forum_post_email_textemail.mustache
View file @
ce878562
...
@@ -45,14 +45,20 @@
...
@@ -45,14 +45,20 @@
{{{
coursename
}}}
->
{{#
str
}}
forums, forum
{{/
str
}}
->
{{{
forumname
}}}{{#
showdiscussionname
}}
->
{{{
discussionname
}}}
{{/
showdiscussionname
}}
{{{
coursename
}}}
->
{{#
str
}}
forums, forum
{{/
str
}}
->
{{{
forumname
}}}{{#
showdiscussionname
}}
->
{{{
discussionname
}}}
{{/
showdiscussionname
}}
{{
permalink
}}
{{
permalink
}}
{{{
subject
}}}
{{{
subject
}}}
{{#
str
}}
bynameondate, forum, { "name": "
{{{
authorfullname
}}}
", "date": "
{{
postdate
}}
" }
{{/
str
}}
{{#
str
}}
bynameondate, forum, {
"name":
{{#
quote
}}{{{
authorfullname
}}}{{/
quote
}}
,
"date":
{{#
quote
}}{{
postdate
}}{{/
quote
}}
}
{{/
str
}}
---------------------------------------------------------------------
---------------------------------------------------------------------
{{{
message
}}}
{{{
message
}}}
{{{
attachments
}}}
{{{
attachments
}}}
---------------------------------------------------------------------
---------------------------------------------------------------------
{{#
canreply
}}
{{#
canreply
}}
{{#
str
}}
postmailinfolink, forum, { "coursename": "
{{{
coursename
}}}
", "replylink": "
{{
replylink
}}
" }
{{/
str
}}
{{#
str
}}
postmailinfolink, forum, {
"coursename":
{{#
quote
}}{{{
coursename
}}}{{/
quote
}}
,
"replylink":
{{#
quote
}}{{
replylink
}}{{/
quote
}}
}
{{/
str
}}
{{/
canreply
}}
{{/
canreply
}}
{{#
unsubscribeforumlink
}}
{{#
unsubscribeforumlink
}}
{{#
str
}}
unsubscribelink, forum,
{{{
unsubscribeforumlink
}}}
{{/
str
}}
{{#
str
}}
unsubscribelink, forum,
{{{
unsubscribeforumlink
}}}
{{/
str
}}
...
...
mod/forum/templates/forum_post_emaildigestbasic_htmlemail.mustache
View file @
ce878562
...
@@ -44,7 +44,7 @@
...
@@ -44,7 +44,7 @@
<div>
<div>
<a
target=
"_blank"
href=
"
{{{
permalink
}}}
"
>
{{{
subject
}}}
</a>
<a
target=
"_blank"
href=
"
{{{
permalink
}}}
"
>
{{{
subject
}}}
</a>
{{#
str
}}
bynameondate, forum, {
{{#
str
}}
bynameondate, forum, {
"name":
"
<a
target=
\"
_blank
\"
href=
\"
{{{
authorlink
}}}
\"
>
{{
authorfullname
}}
</a>
"
,
"name":
{{#
quote
}}
<a
target=
\"
_blank
\"
href=
\"
{{{
authorlink
}}}
\"
>
{{
authorfullname
}}
</a>
{{/
quote
}}
,
"date":
"
{{
postdate
}}
"
"date":
{{#
quote
}}
{{
postdate
}}
{{/
quote
}}
}
{{/
str
}}
}
{{/
str
}}
</div>
</div>
mod/forum/templates/forum_post_emaildigestbasic_textemail.mustache
View file @
ce878562
...
@@ -33,5 +33,8 @@
...
@@ -33,5 +33,8 @@
}}
}}
{{
discussionlink
}}
{{
discussionlink
}}
{{{
subject
}}}
{{#
str
}}
bynameondate, forum, { "name": "
{{{
authorfullname
}}}
", "date": "
{{
postdate
}}
" }
{{/
str
}}
{{{
subject
}}}
{{#
str
}}
bynameondate, forum, {
"name":
{{#
quote
}}{{{
authorfullname
}}}{{/
quote
}}
,
"date":
{{#
quote
}}{{
postdate
}}{{/
quote
}}
}
{{/
str
}}
---------------------------------------------------------------------
---------------------------------------------------------------------
mod/forum/templates/forum_post_emaildigestfull_textemail.mustache
View file @
ce878562
...
@@ -38,7 +38,10 @@
...
@@ -38,7 +38,10 @@
{{
discussionlink
}}
{{
discussionlink
}}
{{{
subject
}}}
(
{{{
permalink
}}}
)
{{{
subject
}}}
(
{{{
permalink
}}}
)
{{#
str
}}
bynameondate, forum, { "name": "
{{{
authorfullname
}}}
", "date": "
{{
postdate
}}
" }
{{/
str
}}
{{#
str
}}
bynameondate, forum, {
"name":
{{#
quote
}}{{{
authorfullname
}}}{{/
quote
}}
,
"date":
{{#
quote
}}{{
postdate
}}{{/
quote
}}
}
{{/
str
}}
---------------------------------------------------------------------
---------------------------------------------------------------------
{{{
message
}}}
{{{
message
}}}
...
...
mod/forum/tests/mail_test.php
View file @
ce878562
...
@@ -879,10 +879,8 @@ class mod_forum_mail_testcase extends advanced_testcase {
...
@@ -879,10 +879,8 @@ class mod_forum_mail_testcase extends advanced_testcase {
// Single and double quotes everywhere.
// Single and double quotes everywhere.
$newcase
=
$base
;
$newcase
=
$base
;
$newcase
[
'user'
][
'lastname'
]
=
'Moodle\''
;
$newcase
[
'user'
][
'lastname'
]
=
'Moodle\'"'
;
// $newcase['user']['lastname'] = 'Moodle\'"'; // TODO: This breaks badly. See MDL-52136.
$newcase
[
'course'
][
'shortname'
]
=
'101\'"'
;
$newcase
[
'course'
][
'shortname'
]
=
'101\''
;
// $newcase['course']['shortname'] = '101\'"'; // TODO: This breaks badly. See MDL-52136.
$newcase
[
'forums'
][
0
][
'name'
]
=
'Moodle Forum\'"'
;
$newcase
[
'forums'
][
0
][
'name'
]
=
'Moodle Forum\'"'
;
$newcase
[
'forums'
][
0
][
'forumposts'
][
0
][
'name'
]
=
'Hello Moodle\'"'
;
$newcase
[
'forums'
][
0
][
'forumposts'
][
0
][
'name'
]
=
'Hello Moodle\'"'
;
$newcase
[
'forums'
][
0
][
'forumposts'
][
0
][
'message'
]
=
'Welcome to Moodle\'"'
;
$newcase
[
'forums'
][
0
][
'forumposts'
][
0
][
'message'
]
=
'Welcome to Moodle\'"'
;
...
@@ -901,8 +899,8 @@ class mod_forum_mail_testcase extends advanced_testcase {
...
@@ -901,8 +899,8 @@ class mod_forum_mail_testcase extends advanced_testcase {
$newcase
[
'forums'
][
0
][
'forumposts'
][
0
][
'name'
]
=
'Hello Moodle>'
;
$newcase
[
'forums'
][
0
][
'forumposts'
][
0
][
'name'
]
=
'Hello Moodle>'
;
$newcase
[
'forums'
][
0
][
'forumposts'
][
0
][
'message'
]
=
'Welcome to Moodle>'
;
$newcase
[
'forums'
][
0
][
'forumposts'
][
0
][
'message'
]
=
'Welcome to Moodle>'
;
$newcase
[
'expectations'
][
0
][
'contents'
]
=
array
(
$newcase
[
'expectations'
][
0
][
'contents'
]
=
array
(
'Attachment example.txt:'
,
'~{\$a'
,
'~&gt;'
,
'Love Moodle>'
,
'101
>
'
,
'Moodle Forum
>
'
,
'Attachment example.txt:'
,
'~{\$a'
,
'~&gt;'
,
'Love Moodle>'
,
'101
>
'
,
'Moodle Forum
>
'
,
'Hello Moodle
>
'
,
'Welcome to Moodle>'
);
'Hello Moodle
>
'
,
'Welcome to Moodle>'
);
$textcases
[
'Text mail with gt and lt everywhere'
]
=
array
(
'data'
=>
$newcase
);
$textcases
[
'Text mail with gt and lt everywhere'
]
=
array
(
'data'
=>
$newcase
);
// Ampersands everywhere. This case is completely borked because format_string()
// Ampersands everywhere. This case is completely borked because format_string()
...
@@ -914,8 +912,8 @@ class mod_forum_mail_testcase extends advanced_testcase {
...
@@ -914,8 +912,8 @@ class mod_forum_mail_testcase extends advanced_testcase {
$newcase
[
'forums'
][
0
][
'forumposts'
][
0
][
'name'
]
=
'Hello Moodle&'
;
$newcase
[
'forums'
][
0
][
'forumposts'
][
0
][
'name'
]
=
'Hello Moodle&'
;
$newcase
[
'forums'
][
0
][
'forumposts'
][
0
][
'message'
]
=
'Welcome to Moodle&'
;
$newcase
[
'forums'
][
0
][
'forumposts'
][
0
][
'message'
]
=
'Welcome to Moodle&'
;
$newcase
[
'expectations'
][
0
][
'contents'
]
=
array
(
$newcase
[
'expectations'
][
0
][
'contents'
]
=
array
(
'Attachment example.txt:'
,
'~{\$a'
,
'~&amp;'
,
'Love Moodle&'
,
'101&
amp;
'
,
'Moodle Forum&
amp;
'
,
'Attachment example.txt:'
,
'~{\$a'
,
'~&amp;'
,
'Love Moodle&'
,
'101&'
,
'Moodle Forum&'
,
'Hello Moodle&
amp;
'
,
'Welcome to Moodle&'
);
'Hello Moodle&'
,
'Welcome to Moodle&'
);
$textcases
[
'Text mail with ampersands everywhere'
]
=
array
(
'data'
=>
$newcase
);
$textcases
[
'Text mail with ampersands everywhere'
]
=
array
(
'data'
=>
$newcase
);
// Now the html cases.
// Now the html cases.
...
@@ -927,25 +925,23 @@ class mod_forum_mail_testcase extends advanced_testcase {
...
@@ -927,25 +925,23 @@ class mod_forum_mail_testcase extends advanced_testcase {
$htmlbase
[
'expectations'
][
0
][
'contents'
]
=
array
(
$htmlbase
[
'expectations'
][
0
][
'contents'
]
=
array
(
'~{\$a'
,
'~{\$a'
,
'~&(amp|lt|gt|quot|\#039);(?!course)'
,
'~&(amp|lt|gt|quot|\#039);(?!course)'
,
'<div class=
3D
"attachments">( *\n *)?<a href'
,
'<div class="attachments">( *\n *)?<a href'
,
'<div class=
3D
"subject">\n.*Hello Moodle'
,
'>Moodle Forum'
,
'>Welcome.*Moodle'
,
'>Love Moodle'
,
'>1\d1'
);
'<div class="subject">\n.*Hello Moodle'
,
'>Moodle Forum'
,
'>Welcome.*Moodle'
,
'>Love Moodle'
,
'>1\d1'
);
$htmlcases
[
'HTML mail without ampersands, quotes or lt/gt'
]
=
array
(
'data'
=>
$htmlbase
);
$htmlcases
[
'HTML mail without ampersands, quotes or lt/gt'
]
=
array
(
'data'
=>
$htmlbase
);
// Single and double quotes, lt and gt, ampersands everywhere.
// Single and double quotes, lt and gt, ampersands everywhere.
$newcase
=
$htmlbase
;
$newcase
=
$htmlbase
;
$newcase
[
'user'
][
'lastname'
]
=
'Moodle\'>&'
;
$newcase
[
'user'
][
'lastname'
]
=
'Moodle\'">&'
;
// $newcase['user']['lastname'] = 'Moodle\'">&'; // TODO: This breaks badly. See MDL-52136.
$newcase
[
'course'
][
'shortname'
]
=
'101\'">&'
;
$newcase
[
'course'
][
'shortname'
]
=
'101\'>&'
;
// $newcase['course']['shortname'] = '101\'">&'; // TODO: This breaks badly. See MDL-52136.
$newcase
[
'forums'
][
0
][
'name'
]
=
'Moodle Forum\'">&'
;
$newcase
[
'forums'
][
0
][
'name'
]
=
'Moodle Forum\'">&'
;
$newcase
[
'forums'
][
0
][
'forumposts'
][
0
][
'name'
]
=
'Hello Moodle\'">&'
;
$newcase
[
'forums'
][
0
][
'forumposts'
][
0
][
'name'
]
=
'Hello Moodle\'">&'
;
$newcase
[
'forums'
][
0
][
'forumposts'
][
0
][
'message'
]
=
'Welcome to Moodle\'">&'
;
$newcase
[
'forums'
][
0
][
'forumposts'
][
0
][
'message'
]
=
'Welcome to Moodle\'">&'
;
$newcase
[
'expectations'
][
0
][
'contents'
]
=
array
(
$newcase
[
'expectations'
][
0
][
'contents'
]
=
array
(
'~{\$a'
,
'~{\$a'
,
'~&(amp|lt|gt|quot|\#039);'
,
'~&(amp|lt|gt|quot|\#039);'
,
'<div class=
3D
"attachments">( *\n *)?<a href'
,
'<div class="attachments">( *\n *)?<a href'
,
'<div class=
3D
"subject">\n.*Hello Moodle\'">&'
,
'>Moodle Forum\'">&'
,
'<div class="subject">\n.*Hello Moodle\'">&'
,
'>Moodle Forum\'">&'
,
'>Welcome.*Moodle\'">&'
,
'>Love Moodle&\#039;>&'
,
'>1
\d
1\'>&'
);
'>Welcome.*Moodle\'">&'
,
'>Love Moodle&\#039;&
quot;&
gt;&'
,
'>1
0
1\'
"
>&'
);
$htmlcases
[
'HTML mail with quotes, gt, lt and ampersand everywhere'
]
=
array
(
'data'
=>
$newcase
);
$htmlcases
[
'HTML mail with quotes, gt, lt and ampersand everywhere'
]
=
array
(
'data'
=>
$newcase
);
return
$textcases
+
$htmlcases
;
return
$textcases
+
$htmlcases
;
...
@@ -1062,6 +1058,7 @@ class mod_forum_mail_testcase extends advanced_testcase {
...
@@ -1062,6 +1058,7 @@ class mod_forum_mail_testcase extends advanced_testcase {
// If we have found the expectation and have contents to match, let's do it.
// If we have found the expectation and have contents to match, let's do it.
if
(
isset
(
$foundexpectation
)
and
isset
(
$foundexpectation
[
'contents'
]))
{
if
(
isset
(
$foundexpectation
)
and
isset
(
$foundexpectation
[
'contents'
]))
{
$mail
->
body
=
quoted_printable_decode
(
$mail
->
body
);
if
(
!
is_array
(
$foundexpectation
[
'contents'
]))
{
// Accept both string and array.
if
(
!
is_array
(
$foundexpectation
[
'contents'
]))
{
// Accept both string and array.
$foundexpectation
[
'contents'
]
=
array
(
$foundexpectation
[
'contents'
]);
$foundexpectation
[
'contents'
]
=
array
(
$foundexpectation
[
'contents'
]);
}
}
...
@@ -1069,6 +1066,7 @@ class mod_forum_mail_testcase extends advanced_testcase {
...
@@ -1069,6 +1066,7 @@ class mod_forum_mail_testcase extends advanced_testcase {
if
(
strpos
(
$content
,
'~'
)
!==
0
)
{
if
(
strpos
(
$content
,
'~'
)
!==
0
)
{
$this
->
assertRegexp
(
'#'
.
$content
.
'#m'
,
$mail
->
body
);
$this
->
assertRegexp
(
'#'
.
$content
.
'#m'
,
$mail
->
body
);
}
else
{
}
else
{
preg_match
(
'#'
.
substr
(
$content
,
1
)
.
'#m'
,
$mail
->
body
,
$matches
);
$this
->
assertNotRegexp
(
'#'
.
substr
(
$content
,
1
)
.
'#m'
,
$mail
->
body
);
$this
->
assertNotRegexp
(
'#'
.
substr
(
$content
,
1
)
.
'#m'
,
$mail
->
body
);
}
}
}
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment