Skip to content

Commit

Permalink
FIX Escape dollar signs in UserForm contents before inserting them wi…
Browse files Browse the repository at this point in the history
…th regex (#723)
  • Loading branch information
scott1702 authored and robbieaverill committed Feb 21, 2018
1 parent eed799d commit 0ce8b95
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions code/model/UserDefinedForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/

class UserDefinedForm extends Page {

/**
* @var string
*/
Expand Down Expand Up @@ -370,7 +370,9 @@ public function index() {
if($this->Content && $form = $this->Form()) {
$hasLocation = stristr($this->Content, '$UserDefinedForm');
if($hasLocation) {
$content = preg_replace('/(<p[^>]*>)?\\$UserDefinedForm(<\\/p>)?/i', $form->forTemplate(), $this->Content);
/** @see Requirements_Backend::escapeReplacement */
$formEscapedForRegex = addcslashes($form->forTemplate(), '\\$');
$content = preg_replace('/(<p[^>]*>)?\\$UserDefinedForm(<\\/p>)?/i', $formEscapedForRegex, $this->Content);
return array(
'Content' => DBField::create_field('HTMLText', $content),
'Form' => ""
Expand Down Expand Up @@ -688,7 +690,7 @@ public function process($data, $form) {
foreach($recipients as $recipient) {
$email = new UserFormRecipientEmail($submittedFields);
$mergeFields = $this->getMergeFieldsMap($emailData['Fields']);

if($attachments) {
foreach($attachments as $file) {
if($file->ID != 0) {
Expand All @@ -700,7 +702,7 @@ public function process($data, $form) {
}
}
}

$parsedBody = SSViewer::execute_string($recipient->getEmailBodyContent(), $mergeFields);

if (!$recipient->SendPlain && $recipient->emailTemplateExists()) {
Expand Down

0 comments on commit 0ce8b95

Please sign in to comment.