# HG changeset patch # User Bill Welliver # Date 1324669302 18000 # Node ID 2245ecc8e644e67b312271edc975f73125c5c455 # Parent b8c895e108181c8e425c6f218e56e719e6ac35ca fixed some errors that are generated by probing robots: handle errors when requesting rss and atom feeds when the associated object doesn't exist, or is not a document / weblog. diff -r b8c895e108181c8e425c6f218e56e719e6ac35ca -r 2245ecc8e644e67b312271edc975f73125c5c455 classes/atom_controller.pike --- a/classes/atom_controller.pike Tue Dec 20 21:14:54 2011 -0500 +++ b/classes/atom_controller.pike Fri Dec 23 14:41:42 2011 -0500 @@ -85,7 +85,8 @@ private void weblog_atom(Fins.Request id, Fins.Response response, object obj, mixed ... args) { - if(obj["datatype"]["mimetype"] != "text/wiki") + // attachments and blog entries cannot be blogs. + if(obj["is_attachment"]!=0) { response->flash("msg", "page requested is not a weblog.\n"); response->redirect("/exec/notfound/" + args*"/"); @@ -103,12 +104,12 @@ } private void comments_atom(Fins.Request id, Fins.Response response, - object obj, mixed ... args) + object obj, array args) { - if(obj["datatype"]["mimetype"] != "text/wiki") + if(obj["is_attachment"] == 1) { - response->flash("msg", "page requested is not a wiki page.\n"); - response->redirect("/exec/notfound/" + args*"/"); + response->flash("msg", "document requested cannot contain comments.\n"); + response->redirect("/exec/notfound/" + args*"/"); return 0; } diff -r b8c895e108181c8e425c6f218e56e719e6ac35ca -r 2245ecc8e644e67b312271edc975f73125c5c455 classes/exec_controller.pike --- a/classes/exec_controller.pike Tue Dec 20 21:14:54 2011 -0500 +++ b/classes/exec_controller.pike Fri Dec 23 14:41:42 2011 -0500 @@ -4,6 +4,8 @@ #define LOCALE(X,Y) Locale.translate(config->app_name, id->get_lang(), X, Y) +#define NOTFOUND(X,Y) { response->flash("msg", "Unable to perform action " + X + " for document " + (Y*"/") + "."); response->redirect(notfound, Y); return;} + import Tools.Logging; import Fins; import Fins.Model; @@ -830,8 +832,6 @@ string contents, title, obj; object obj_o; -werror("POST: %O %O\n", args*"/", id->variables); - int anonymous = app->get_sys_pref("comments.anonymous")->get_value(); if(!id->misc->session_variables->userid && @@ -856,7 +856,8 @@ id->misc->anonymous = anonymous; obj_o = model->get_fbobject(args, id); - + if(!obj_o) + NOTFOUND("comments", args); if(obj_o["md"]["comments_closed"] == 1) { if(id->variables->ajax) diff -r b8c895e108181c8e425c6f218e56e719e6ac35ca -r 2245ecc8e644e67b312271edc975f73125c5c455 classes/rss_controller.pike --- a/classes/rss_controller.pike Tue Dec 20 21:14:54 2011 -0500 +++ b/classes/rss_controller.pike Fri Dec 23 14:41:42 2011 -0500 @@ -59,7 +59,8 @@ private void weblog_rss(Fins.Request id, Fins.Response response, object obj, mixed ... args) { - if(obj["datatype"]["mimetype"] != "text/wiki") + // attachments and blog entries cannot be blogs. + if(obj["is_attachment"]!=0) { response->flash("msg", "page requested is not a weblog.\n"); response->redirect("/exec/notfound/" + args*"/"); @@ -76,13 +77,13 @@ private void comments_rss(Fins.Request id, Fins.Response response, object obj, mixed ... args) { - if(obj["datatype"]["mimetype"] != "text/wiki") + if(obj["is_attachment"] == 1) { - response->flash("msg", "page requested is not a wiki page.\n"); - response->redirect("/exec/notfound/" + args*"/"); - return; + response->flash("msg", "document requested cannot contain comments.\n"); + response->redirect("/exec/notfound/" + args*"/"); + return 0; } - + array o = obj["comments"]; Node n = generate_comments_rss(obj, o, id); diff -r b8c895e108181c8e425c6f218e56e719e6ac35ca -r 2245ecc8e644e67b312271edc975f73125c5c455 templates/exec/objectnotfound.phtml --- a/templates/exec/objectnotfound.phtml Tue Dec 20 21:14:54 2011 -0500 +++ b/templates/exec/objectnotfound.phtml Fri Dec 23 14:41:42 2011 -0500 @@ -5,6 +5,7 @@

<%LOCALE id="280" string="Whoops!"%>

+
<%flash %>
<%LOCALE id="281" string="The page you requested,"%> <%$obj%>, <%LOCALE id="282" string="could not be found."%>