Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTML tags around email addresses produce mangled ouput #565

Closed
pgorman opened this issue Mar 9, 2018 · 1 comment
Closed

HTML tags around email addresses produce mangled ouput #565

pgorman opened this issue Mar 9, 2018 · 1 comment
Milestone

Comments

@pgorman
Copy link

pgorman commented Mar 9, 2018

I expect input like <strong>first.last@example.com</strong> to produce output like <strong>first.last@example.com</strong>. Instead, we see output like <a href="mailto:strong&gt;first.last@example.com&lt;/strong">strong&gt;first.last@example.com&lt;/strong</a>.

I suggest something like:

diff --git a/Parsedown.php b/Parsedown.php
index 87d612a..39a3aed 100644
--- a/Parsedown.php
+++ b/Parsedown.php
@@ -1146,6 +1146,10 @@ class Parsedown
         {
             $url = $matches[1];
 
+            if (!filter_var($url, FILTER_VALIDATE_EMAIL)) {
+                return;
+            }
+
             if ( ! isset($matches[2]))
             {
                 $url = 'mailto:' . $url;
@aidantwoods
Copy link
Collaborator

Seeing the encoded output there I was initially a little worried it might be a regression related to the encoding Parsedown does now. Looks like a previous version of Parsedown gave

<p><a href="mailto:strong>first.last@example.com</strong">strong>first.last@example.com</strong</a></p>

so this is in-fact not a regression at least ;p.

You're correct in identifying the source of the error too, this should be fixed in #566 :)

aidantwoods added a commit to aidantwoods/parsedown that referenced this issue Mar 9, 2018
@aidantwoods aidantwoods added this to the 1.8.0 milestone Mar 28, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants