Note: the above code wont support the generated images like this url:
http://www.gravatar.com/avatar/7398043db822737c675dceff4fc86446?s=48&d=&r=g
as it doesn't end with .png, .jpg, .jpeg, or .gif
If you want these images to be displayed, then just comment out this line:
add_filter( 'pre_post', 'allow_images', 52 );
But note that it would be no longer safe.
The above code is also compatible with bb 1.0.1
