소스 검색

Change email bbcode

Change the handler so that the html validator doesn't swear at bad emails addresses.
Symbols ', '', < and > will be encoded htmlspecialchars() function, rather than rawurlencode(). That is, addresses with such symbols will be unsuitable for transfer to the postal program.
Visman 4 년 전
부모
커밋
a0a49f99a9
1개의 변경된 파일9개의 추가작업 그리고 4개의 파일을 삭제
  1. 9 4
      app/config/defaultBBCode.php

+ 9 - 4
app/config/defaultBBCode.php

@@ -203,11 +203,16 @@ HANDLER,
             ],
         ],
         'handler' => <<<'HANDLER'
-if (empty($attrs['Def'])) {
-    $attrs['Def'] = $body;
-}
+$def = $attrs['Def'] ?? $body;
+$def = \implode('@',
+    \array_map('\\rawurlencode',
+        \array_map('\\rawurldecode',
+            \explode('@', $def)
+        )
+    )
+);
 
-return "<a href=\"mailto:{$attrs['Def']}\">{$body}</a>";
+return "<a href=\"mailto:{$def}\">{$body}</a>";
 HANDLER,
     ],
     [