Ah-ha! I think I know what the problem is ... (and yes it would be a bug in the package!) ... the code that processes the HTML for the "mailto" links is done in a Response.Filter, which that content can be buffered into chunks. Obviously my test pages haven't been large enough to hit that buffer, so I haven't seen it in chunks.
I'll look at fixing this bug later today (can't make any promises - I've got a heavy workload).
Would you be able to drop me an email? (via my contact form)
Once I reply, it would be good to see a full example of the HTML source (from the rich-text editor) ... I appreciate that you can't post it on the forum (sensitive email addresses, etc). Would be good for me to have a real-world example of the content to test against.
Had to take the day off work on Friday due to illness :-$ (Feeling much better now!)
I have ran a few tests on the HTML that you sent to me ... the mailto links encoded correctly and there were no other malformed HTML tags, (I checked the Facebook links, they were fine too).
Thinking this is related to the response buffer set by IIS, but not sure what to do about it at the moment. Hmmm, I'll give it some more thought.
just to let you know that this is no isolated occurrence: I do experience the same "broken markup" problem with v1.0.1. It's only with this release while 1.0.0 work flawlessly in that respect (while missing many links due to the chunking issue mentioned above).
After some more research into the chunking issue (with Response.Filters), I believe I have a solution... aiming to schedule in a new fix release in the next couple of days (workload/dayjob permitting).
unfortunately there seem to be an issue with the new approach when the page uses RenderTemplate (uComponents):
System.Web.HttpUnhandledException (0x80004005): Exception of type 'System.Web.HttpUnhandledException' was thrown. ---> System.Web.HttpException (0x80004005): Filtering is not allowed. at System.Web.HttpResponse.set_Filter(Stream value) at Our.Umbraco.SafeMailLink.Events.ApplicationEventsHandler.UmbracoDefault_BeforeRequestInit(Object sender, RequestInitEventArgs e) at umbraco.UmbracoDefault.FireBeforeRequestInit(RequestInitEventArgs e) at umbraco.UmbracoDefault.initUmbracoPage() at umbraco.UmbracoDefault.Page_PreInit(Object sender, EventArgs e) at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) at System.Web.UI.Page.OnPreInit(EventArgs e) at System.Web.UI.Page.PerformPreInit() at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) at System.Web.UI.Page.HandleError(Exception e) at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) at System.Web.UI.Page.ProcessRequest() at System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context) at System.Web.UI.Page.ProcessRequest(HttpContext context) at ASP.default_aspx.ProcessRequest([..]
OK, hopefully I've resolved the issue. Released v1.1.
Technical explanation: for v1.0.2, I'd removed the HttpModule and tried using Umbraco's exposed Page_Init event to hook in the Response.Filter ... but obviously that doesn't work with RenderTemple ... so for v1.1, I've reverted back to using a HttpModule (which should work with RenderTemplate) and still keeping the solution for the buffering/chunking issue! (phew!!!)
Seems like the filter module isn't invoked at all. AFAIR the assembly attaches the IHttpModule+Filter automatically on application startup. Are you absolutely sure that the assembly is in /bin?
I can confirm that we have the assembly running on 4.9 installs without problems and mailto links are handled as they should.
I've just tested your plugin and it's really straight forward. Thanks a lot for that. I've just experienced one issue: Links created within the umbraco rich text editor arn't converted. Links inserted into the template, textstring and textboxmultiple fields are converted correctly. The output from the richt text editor is:
This is really strange, Nora. Alerted by your post, I checked several sites to see if we have the same issue (which obviously wouldn't have been good news at all). But every mail link is converted as expected. I explicitly checked for RTE inserted links. Can confirm all is working with several 4.9, 4.8.1 and 4.7.2 sites. The module is working on filter level with the complete (final) page output, if I recall correctly and thus doesn't care how content is rendered (usercontrol, template, xslt, razor, ...).
Could it be that you do some kind of "double encoding" while outputting the RTE contents? If the browsers would handle this gracefully and render the content it could be nonetheless the case that the regexp that is at the heart of the Safe Mail Link module isn't picking these encoded mail links up?! Just a vague idea ...
thanks for your quick response and your help. I've been dealing around with this issue for some time and now noticed that there is one mail adress coming from a rte-field, which does convert correctly. So my conclusion that it must be related to the rich text editor was not correct. I've now copied the content from the rte where it worked to the other page - and the issue seems to be resolved.
I don't know about any known issues; IMHO Lee would have solved it then. Nevertheless as the page's output markup is handled by some regex, it could miss in some circumstances, sure.
But because your posted markup looks invalid (maybe because of the forum editor) or at least invomplete, I can't comment on the examples. Probably you could post the two snippets somewhere and insert a link here?
@Marc: Thanks for picking up on this thread - very much appreciated!
@Nora: I'll try to reproduce your issue later today (hopefully) ... if there is an issue, Marc is correct with it would be with the RegEx match - so would try to put out a fix for it. I'll keep you posted.
@ Marc: I guess you do use E-Mail-Links with text before them in the same paragraph coming from a rich-text-editor-field without problems?!? Could the problem occurring in this case be related to the umbraco version? The site is running on umbraco v 4.7.2 (Assembly version: 1.0.4500.21031).
Sorry, no 4.7.2 (w/ Safe Mail Link) instance available, where I'm allowed change content for a quick test ...
I honestly have no idea how the umbraco version could make the difference - only because of the RTE/TinyMCE part probably; but not between 4.7.1.1 and 4.7.2 I'd say. This is really some strange bug ...
@Nora: What's the URL of the page that this happens on? I might have found a bug with the package, (when it checks the URL to make sure it's not a path reserved by Umbraco core).
@Lee: Thanks a lot for the immediate help. I've sent you the URL via your contact form. (http://leekelleher.com/contact/) Would be great if you already discovered the problem.
Following up on Nora's email to me (which contained links to a private website), I was able to find the bug. For whatever reason the HTML from the rich-text editor seemed to wrap after a number of characters (about 75 chars). This meant that some HTML tags had line-breaks in them.
The RegEx used for SafeMailLink doesn't take line-breaks into account, so didn't match the mailto link. It should be a simple fix/patch. I'll let you know once it's ready.
Some links aren't encoded
Hi
I've got a problem with the SafeMailLink.
I've a node with a lot of emails in the content, which aren't encoded, but the email in the footer is encoded?!
My page looks like (HTML divs):
- navi [0 email-links]
- wrapper, content [12 email-links]
- header [0 email-links]
- footer [1 email-link]
My first thought was, that the html of the page is to big, but why can he encode the link in the footer?
Cheers
Calvin
Hi Calvin,
Are the email addresses in the main content section using "mailto" links?
Thanks, Lee.
Hi Lee
Yes they are. This is my HTML (short version ;-)):
<body>
<ul id="navi">
...
</ul>
<div id="wrapper">
<div id="content">
<table id="addresses">
<tr>
....
</tr>
<tr>
<td>Firstname lastname</td>
<td><a href=''mailto:[email protected]'' title="Send mail to ...">[email protected]</a>
</tr>
(13 more lines like the above)
</table>
</div>
</div>
<div id="header">
....
</div>
<div id="footer">
..... <a href=''mailto:[email protected]'' title="Send mail to [email protected]">[email protected]</a>
</div>
</body>
When I delete some lines from the table, it works.
I hope you understand my problem :-).
Ah-ha! I think I know what the problem is ... (and yes it would be a bug in the package!) ... the code that processes the HTML for the "mailto" links is done in a Response.Filter, which that content can be buffered into chunks. Obviously my test pages haven't been large enough to hit that buffer, so I haven't seen it in chunks.
I'll look at fixing this bug later today (can't make any promises - I've got a heavy workload).
Thanks, Lee.
Okay cool, I'll wait for your fix :-D.
THANKS!
Calvin
Just released v1.0.1 of the package. This should resolve your issues. Let me know if any other issues arise.
Cheers, Lee.
Thanks Lee for your release.
When there are a few of emails it makes this output:
<a href="{encodedMail}" title="Mail to xyz">asd<!--y-->.asd@<!--x-->test<!--y-->.ch</a>a href=http://www.facebook.com/pages/mypage target="_blank" title="Go to facebook page">My page</a>
The second a-tag looks bad, it misses the "<" and bricks the whole HTML.
Can you help me again :-)?
Hi Calvin,
Would you be able to drop me an email? (via my contact form)
Once I reply, it would be good to see a full example of the HTML source (from the rich-text editor) ... I appreciate that you can't post it on the forum (sensitive email addresses, etc). Would be good for me to have a real-world example of the content to test against.
Thanks, Lee.
Did you get my mail?
Cheers
Calvin
Hi Calvin,
Had to take the day off work on Friday due to illness :-$ (Feeling much better now!)
I have ran a few tests on the HTML that you sent to me ... the mailto links encoded correctly and there were no other malformed HTML tags, (I checked the Facebook links, they were fine too).
Thinking this is related to the response buffer set by IIS, but not sure what to do about it at the moment. Hmmm, I'll give it some more thought.
Cheers, Lee.
Hi Lee, Calvin,
just to let you know that this is no isolated occurrence: I do experience the same "broken markup" problem with v1.0.1. It's only with this release while 1.0.0 work flawlessly in that respect (while missing many links due to the chunking issue mentioned above).
Marc
Hi Marc, Calvin,
After some more research into the chunking issue (with Response.Filters), I believe I have a solution... aiming to schedule in a new fix release in the next couple of days (workload/dayjob permitting).
Cheers, Lee.
Excellent, Lee. Thanks for the status update and all the work you put into this.
Marc.
Hi Marc, Calvin,
Just released v1.0.2 ... ended up being a bit more of a rewrite, but I think it performs better now (and should resolve the buffer/chunking issue).
Let me know how it goes.
Cheers, Lee.
Hi Lee,
looking good so far! No more scrambled rendering and all the mailto-links are handled.
Thanks! Great package!
Marc.
Hi Lee,
unfortunately there seem to be an issue with the new approach when the page uses RenderTemplate (uComponents):
System.Web.HttpUnhandledException (0x80004005): Exception of type 'System.Web.HttpUnhandledException' was thrown. ---> System.Web.HttpException (0x80004005): Filtering is not allowed. at System.Web.HttpResponse.set_Filter(Stream value) at Our.Umbraco.SafeMailLink.Events.ApplicationEventsHandler.UmbracoDefault_BeforeRequestInit(Object sender, RequestInitEventArgs e) at umbraco.UmbracoDefault.FireBeforeRequestInit(RequestInitEventArgs e) at umbraco.UmbracoDefault.initUmbracoPage() at umbraco.UmbracoDefault.Page_PreInit(Object sender, EventArgs e) at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) at System.Web.UI.Page.OnPreInit(EventArgs e) at System.Web.UI.Page.PerformPreInit() at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) at System.Web.UI.Page.HandleError(Exception e) at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) at System.Web.UI.Page.ProcessRequest() at System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context) at System.Web.UI.Page.ProcessRequest(HttpContext context) at ASP.default_aspx.ProcessRequest([..]Any idea?
Marc.
Thanks for the feedback Marc, much appreciated. I need a better test suite for this (at the moment, I've just got a page full of mailto links).
I'll take a look at the code, see if I can resolve this issue.
Cheers, Lee.
Hi Marc,
OK, hopefully I've resolved the issue. Released v1.1.
Technical explanation: for v1.0.2, I'd removed the HttpModule and tried using Umbraco's exposed Page_Init event to hook in the Response.Filter ... but obviously that doesn't work with RenderTemple ... so for v1.1, I've reverted back to using a HttpModule (which should work with RenderTemplate) and still keeping the solution for the buffering/chunking issue! (phew!!!)
Let me know if there are any further problems.
Cheers, Lee.
Hi Lee,
looks promising: All pages display correctly.
Thanks for putting out all the fixes so rapidly!
Marc.
IT WORKS ;-)! Nice, many thanks to you Lee.
I mark your v1.1 as the solution.
Thanks to you Lee!
Calvin
This is not working at all on Umbraco 4.9
Rendered code is as follows:
Any ideas why?
Seems like the filter module isn't invoked at all. AFAIR the assembly attaches the IHttpModule+Filter automatically on application startup. Are you absolutely sure that the assembly is in /bin?
I can confirm that we have the assembly running on 4.9 installs without problems and mailto links are handled as they should.
Marc.
The binary "Our.Umbraco.SafeMailLink.dll" is in the bin folder.
Hi Lee,
I've just tested your plugin and it's really straight forward. Thanks a lot for that. I've just experienced one issue: Links created within the umbraco rich text editor arn't converted. Links inserted into the template, textstring and textboxmultiple fields are converted correctly. The output from the richt text editor is:
I do not see any difference to the links converted correctly. Any ideas what could be the issue here?
Thanks a lot.
Nora
This is really strange, Nora. Alerted by your post, I checked several sites to see if we have the same issue (which obviously wouldn't have been good news at all). But every mail link is converted as expected. I explicitly checked for RTE inserted links. Can confirm all is working with several 4.9, 4.8.1 and 4.7.2 sites. The module is working on filter level with the complete (final) page output, if I recall correctly and thus doesn't care how content is rendered (usercontrol, template, xslt, razor, ...).
Could it be that you do some kind of "double encoding" while outputting the RTE contents? If the browsers would handle this gracefully and render the content it could be nonetheless the case that the regexp that is at the heart of the Safe Mail Link module isn't picking these encoded mail links up?! Just a vague idea ...
Marc
Hi Marc,
thanks for your quick response and your help. I've been dealing around with this issue for some time and now noticed that there is one mail adress coming from a rte-field, which does convert correctly. So my conclusion that it must be related to the rich text editor was not correct. I've now copied the content from the rte where it worked to the other page - and the issue seems to be resolved.
html-input rte - not working:
html-input rte - working correctly:
On another page with this issue I deleted the "E-Mail:" before the a-element and it worked. If I insert it again, the link is not converted ?!?
Is there any known issue about content before or after the a-element?
Thanks a lot.
Nora
Hey Nora,
I don't know about any known issues; IMHO Lee would have solved it then. Nevertheless as the page's output markup is handled by some regex, it could miss in some circumstances, sure.
But because your posted markup looks invalid (maybe because of the forum editor) or at least invomplete, I can't comment on the examples. Probably you could post the two snippets somewhere and insert a link here?
If you want to take a look at the regex or want to play around with it and your markup to find out more, here's the link to the source file containing the relevant expression: https://bitbucket.org/vertino/safemaillink-for-umbraco/src/3e798f2f41d0/Our.Umbraco.SafeMailLink/Utilities/Parser.cs
Marc.
@Marc: Thanks for picking up on this thread - very much appreciated!
@Nora: I'll try to reproduce your issue later today (hopefully) ... if there is an issue, Marc is correct with it would be with the RegEx match - so would try to put out a fix for it. I'll keep you posted.
Thanks, Lee.
Hi Marc, Hi Lee,
thank you very much for your help and the quick responses. I'm sorry - it seems that the posted markup got mixed up a little bit. Another try:
working correctly:
not working:
@ Marc: I guess you do use E-Mail-Links with text before them in the same paragraph coming from a rich-text-editor-field without problems?!? Could the problem occurring in this case be related to the umbraco version? The site is running on umbraco v 4.7.2 (Assembly version: 1.0.4500.21031).
Thanks a lot, Nora.
Hey Nora,
I tested your exact case ("E-Mail:" before a-Tag) on a 4.9 and on 4.7.1.1 site. Works as expected:
Sorry, no 4.7.2 (w/ Safe Mail Link) instance available, where I'm allowed change content for a quick test ...
I honestly have no idea how the umbraco version could make the difference - only because of the RTE/TinyMCE part probably; but not between 4.7.1.1 and 4.7.2 I'd say. This is really some strange bug ...
Marc.
@Nora: What's the URL of the page that this happens on? I might have found a bug with the package, (when it checks the URL to make sure it's not a path reserved by Umbraco core).
Thanks, Lee.
@Lee: Thanks a lot for the immediate help. I've sent you the URL via your contact form. (http://leekelleher.com/contact/) Would be great if you already discovered the problem.
@Marc: Thank you for testing and your help.
Have a nice day :)
Nora
Following up on Nora's email to me (which contained links to a private website), I was able to find the bug. For whatever reason the HTML from the rich-text editor seemed to wrap after a number of characters (about 75 chars). This meant that some HTML tags had line-breaks in them.
e.g.
The RegEx used for SafeMailLink doesn't take line-breaks into account, so didn't match the mailto link. It should be a simple fix/patch. I'll let you know once it's ready.
Cheers, Lee.
Turned out to a super quick fix. SafeMailLink_1.3.0.zip is ready for download!
Hi Lee,
wow – great news! Thank you very much for the investigation and the quick support :)
Have a nice day and thanks again, Nora
That explains why it wasn't easy to reproduce. Good find, Nora. And Lee, as usual, thanks for getting it fixed! :)
Marc.
is working on a reply...