Closed (fixed)
Project:
Mime Mail
Version:
5.x-1.x-dev
Component:
Code
Priority:
Critical
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
2 Apr 2007 at 11:35 UTC
Updated:
3 Mar 2008 at 00:52 UTC
Jump to comment: Most recent file
Comments
Comment #1
jsloan commentedThis bug bit me today and in looking through the process I found that your suspicion is correct.
The problem is that when using ltrim() it will continue its replacement until it encounters a character that is not in the $charlist of the second parameter. http://us2.php.net/ltrim This is not a substring replacement function it is a "trim" using any character in the supplied list.
I suggest using preg_replace() instead of ereg_replace() and adding the limit to equal 1 so that it only removes the beginning of the URL.
I think that this line should be refactored to unravel its complexity. I'll try to submit a patch later.
Comment #2
jsloan commented... here's a patch.
Comment #3
cburschkaIssues with patches should be flagged accordingly to avoid falling under the radar.
I can't test this, but both the problem and the fix look fairly straightforward. ltrim() is really just wrong for this purpose, as mentioned - ltrim()'s second parameter is not a string to remove, it's simply a blacklist of trimmable characters. That it succeeds is a matter of luck.
Analogy: ltrim("apples/bananas","apples/") -> "bananas" works (by chance!), but
ltrim("bakery/bananas","bakery/") -> "nanas" simply gets nonsensical results.
Comment #4
coltranePatch tested and works correctly.
Comment #5
smithwib commentedOne additional observation. One of my sites on a Windows box running IIS does not use the RewriteEngine and does not always have clean URLs, so the URLs submitted to _mimemail_url may look like "/?q=services" or "/?q=node/23". What I have found properly adjusts these is to use:
$url = preg_replace( "!".base_path()."(index.php)?!", "", $url,1 );Comment #6
michelleFixed the problem I was having with this on a client site. Thanks!
Michelle
Comment #7
jerdavisI wasn't able to reproduce the issue on my test site, as I wasn't sure how to configure to reproduce it. I also had a problem applying the patch linked above and as such, i've re-factored it a bit. The included patch file should work. Testing it, I did not see any issues.
Comment #8
jerdavisUploading an updates patch, this patch takes into account the "Code Cleanup" patch from: http://drupal.org/node/220432
This update requires that patch prior to being applied.
Comment #9
allie mickaCommitted to HEAD, will roll a D5 release soon. Thanks!
Comment #10
Anonymous (not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.