Dealing with malformed atom requests in Drupal

Recently a mostly annoying occurrence was filling up my log files with errors. The problem seems to be with some atom news readers. The standard atom feed for this site would get turned into a request that would be "/atom/atom/atom/atom".... and so on. Often longer than Apache knew what to do with it.

So, a single line added to the httpd.conf file solves the problem.

  RewriteRule ^(.*)atom/atom(.*)$ - [G,L]

Now the request is met with a 410 error - resource gone. With a little luck this will lead the coders of the errant software to start picking up on the problem.

Category: 

2 Comments

.htaccess

I should have noted that the same line will work when added to Drupal's default .htaccess as long as it's added before the RewriteCond statements for the Drupal distribution and after Rewrite is turned on.

known bug

The problem is the atom module actually prints output for recursive URLs. Going to /atom/feed/atom actually prints the feed (which isn't blocked by your rewrite rule), when it should 404. There's a bug filed at http://drupal.org/node/41482, which I've looked at, but I can't seem to identify could be changed to make it 404.