Fixed encoding in contact form emails
authorMarcel Werk <burntime@woltlab.com>
Wed, 2 Oct 2019 14:52:32 +0000 (16:52 +0200)
committerMarcel Werk <burntime@woltlab.com>
Wed, 2 Oct 2019 14:52:32 +0000 (16:52 +0200)
wcfsetup/install/files/lib/data/contact/option/ContactOptionAction.class.php
wcfsetup/install/files/lib/data/custom/option/CustomOption.class.php
wcfsetup/install/lang/de.xml
wcfsetup/install/lang/en.xml

index f3b36a9475d4c3d06cdbdd89a0a14d9c425da168..644fcaffe5cfdd3985894f8014d04c1e564e11ff 100644 (file)
@@ -64,7 +64,8 @@ class ContactOptionAction extends CustomOptionAction {
                        $options[] = [
                                'isMessage' => $object->isMessage(),
                                'title' => $object->getLocalizedName($defaultLanguage),
-                               'value' => $object->getFormattedOptionValue(true)
+                               'value' => $object->getFormattedOptionValue(true),
+                               'htmlValue' => $object->getFormattedOptionValue(),
                        ];
                }
                
index dc99686f6c8a8dce982a188803b806bf5617c00b..5f180c89b7b9f24a2395de412f8bfab15c05b697 100644 (file)
@@ -114,7 +114,7 @@ abstract class CustomOption extends Option {
                        case 'radioButton':
                        case 'select':
                                $selectOptions = OptionUtil::parseSelectOptions($this->selectOptions);
-                               if (isset($selectOptions[$this->optionValue])) return WCF::getLanguage()->get($selectOptions[$this->optionValue]);
+                               if (isset($selectOptions[$this->optionValue])) return WCF::getLanguage()->get(($forcePlaintext ? $selectOptions[$this->optionValue] : StringUtil::encodeHTML($selectOptions[$this->optionValue])));
                                return '';
                                
                        case 'multiSelect':
@@ -124,8 +124,11 @@ abstract class CustomOption extends Option {
                                $result = '';
                                foreach ($values as $value) {
                                        if (isset($selectOptions[$value])) {
-                                               if (!empty($result)) $result .= "<br>\n";
-                                               $result .= WCF::getLanguage()->get($selectOptions[$value]);
+                                               if (!empty($result)) {
+                                                       if ($forcePlaintext) $result .= "\n";
+                                                       else $result .= "<br>";
+                                               }
+                                               $result .= WCF::getLanguage()->get(($forcePlaintext ? $selectOptions[$value] : StringUtil::encodeHTML($selectOptions[$value])));
                                        }
                                }
                                return $result;
@@ -146,7 +149,8 @@ abstract class CustomOption extends Option {
                                // fallthrough
                                
                        default:
-                               return StringUtil::encodeHTML($this->optionValue);
+                               if (!$forcePlaintext) return StringUtil::encodeHTML($this->optionValue);
+                               return $this->optionValue;
                }
        }
        
index 677ea66cafd4e4300288615489008bc429aec913..0b740a3e7e0ddbdf4718586b6a7525e26c0aa331 100644 (file)
@@ -2549,8 +2549,7 @@ E-Mail-Adresse: {@$emailAddress} {* this line ends with a space *}
 <p><br></p>
 <p>E-Mail-Adresse: <a href="mailto:{$emailAddress}">{$emailAddress}</a></p>
 {foreach from=$options item=option}
-<p><strong>{@$option['title']}:</strong> {if !$option['isMessage']}{@$option['value']}{else}
-{@$option['value']|newlineToBreak}{/if}</p>
+<p><strong>{@$option['title']}:</strong> {@$option['htmlValue']}</p>
 {/foreach}]]></item>
                <item name="wcf.contact.option1"><![CDATA[Betreff]]></item>
                <item name="wcf.contact.optionDescription1"><![CDATA[Kurze, prägnante Beschreibung der Anfrage.]]></item>
index 0fc84e44d8a2235f216a54665eb5427167532e8d..60391556af3d8765d1979412b99601bcf4c0ba9d 100644 (file)
@@ -2487,8 +2487,7 @@ Email: {@$emailAddress} {* this line ends with a space *}
 <p><br></p>
 <p>Email: <a href="mailto:{$emailAddress}">{$emailAddress}</a></p>
 {foreach from=$options item=option}
-<p><strong>{@$option['title']}:</strong> {if !$option['isMessage']}{@$option['value']}{else}
-{@$option['value']|newlineToBreak}{/if}</p>
+<p><strong>{@$option['title']}:</strong> {@$option['htmlValue']}</p>
 {/foreach}]]></item>
                <item name="wcf.contact.option1"><![CDATA[Subject]]></item>
                <item name="wcf.contact.optionDescription1"><![CDATA[Short and precise description of your inquiry.]]></item>