Fixing bugs for emailcloak plugin

Hi everyone!

This PR tries to adapt changes that were made to the 3.x version of the emailcloak plugin. These changes fixed several bugs, so they should be implemented in 2.5.x, too. One of these bugs is #3956, which was fixed for 3.x yesterday. 
As I don't have much time to test this PR right now, I ask you to test this thoroughly, so that we don't have to release three more versions until mailcloaking works again. I'll test the PR tonight or tomorrow by myself. But because this fixes some major and urgent bugs, I'm proposing it only rarely tested.

## Testing instructions
Please test **all** variants to use this plugin:
1. ```<a href="http://mce_host/ourdirectory/email@example.org">email@example.org</a>```
2. ```<a href="http://mce_host/ourdirectory/email@example.org">text</a>```
3. ```<a href="mailto:email@example.org">email@example.org</a>```
4. ```<a href="mailto:email@example.org">text</a>```
5. ```<a href="mailto:email@example.org"><img src="..." /></a>```
6. ```<a href="mailto:email@example.org?subject=Text">email@example.org</a>```
7. ```<a href="mailto:email@example.org?subject=Text">text</a>```
8. ```<a href="mailto:email@example.org?subject=Text"><img src="..." /></a>```
9. plain ```email@example.org```
...and please test all of these variants with attributes, such as class and style attributes before and after the href attribute.