Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

[BUG] formatting email addresses

ithcyithcy New
edited September 2010 in Vanilla 2.0 - 2.8
Hi,

There is a bug in the current (non-SVN) Vanilla 2 download. (EDIT: the bug exists in at least the v2.0.3 and v2.0.6 downloads.) You may have noticed that when you go to your profile page, your email address looks like this:
Email: xxx@xxx.com">xxx@xxx.com...

The anonymous function inside the livequery at global.js::158 is running at least twice, causing the email address span to be wrapped in multiple layers of <a href="mailto">...</a>.

My fix is to provide an extra class to the email span when it's printed out to HTML, and then strip out that class inside the anonymous function, so the selector doesn't match anymore on subsequent firings of that livequery event. I'm sure there are other ways to fix it but this works fine.

There are two patches // EDIT: see my comment below for the fixes

Note: I also cleaned up all of the $(this) inside that JS function. It's never a great idea to use $() multple times inside a loop to access the same jQuery object. I think global.js could benefit from a lot more caching and other performance tweaks.
Tagged:

Comments

  • ithcyithcy New
    edited August 2010
    Confirmed that this also bug also manifests on the user list page. I guess it will show up anywhere the Email output formatter is used.
  • @ithcy; I'm on 2.0.3 and am not seeing this issue at all.

  • ithcy

    I am on 2.0.3 and am having this problem. Is the above code just inserted anywhere in the library/core.format.php: and in the js/global.js:???

    TIA
  • ithcyithcy New
    edited September 2010
    no, those are just patches. here's what you can do:

    in library/core/class.format.php (i had a typo in that filename), look around line 383 for the line that starts like this:
    return '<span class="Email">' and just insert " unformatted" (with the space) after that Email. So that line will now start like this:
    return '<span class="Email EmailUnformatted">'

    Then in js/global.js, look around line 157 for this block:
    // Format email addresses $('span.Email').livequery(function() { var html = $(this).html(); var email = $(this).html().replace(/<em>dot<\/em>/ig, '.').replace(/<strong>at<\/strong>/ig, '@'); $(this).html('<a href="mailto:' + email + '">' + email + '</a>'); }); and replace it with this: // Format email addresses $('span.Email.EmailUnformatted').livequery(function() { var el = $(this); el.removeClass('EmailUnformatted'); var email = el.html().replace(/<em>dot<\/em>/ig, '.').replace(/<strong>at<\/strong>/ig, '@'); el.html('<a href="mailto:' + email + '">' + email + '</a>'); });
  • Ok icthy,

    Since making the changes suggested my email address looks like this: myname@test.com"> Getting closer but I double checked my editing and it appears correct. Bought my first book on learning this language so I am not at the point I understand this yet! Also, as you stated the user list page still has duplicates. Any chance you are working on a fix for that? Also, a general question, since I have edited a number of files to get features/plugins to function since the first version of Vanilla, how are these patches handled. Do you submit them to the Vanilla team and they include them in the future releases or do I just need to keep notes so when I upgrade versions I don't keep losing the patched files?

    Thanks!
  • Ok icthy,

    This morning I had the above problems with 2.0.6 and with 2.0.3 before the upgrade. Spent the day testing the new version, disabling plugins, trying to get themes to work when I noticed the userlist AND user email panel now displays the correct information. No duplicates. I have left your edits in and everything seems to be working now. I wish I knew what I had done to correct the problem.

    Thanks!
Sign In or Register to comment.