Index: openacs-4/packages/acs-tcl/tcl/tcl-documentation-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/tcl-documentation-procs.tcl,v diff -u -r1.61.2.38 -r1.61.2.39 --- openacs-4/packages/acs-tcl/tcl/tcl-documentation-procs.tcl 16 Mar 2023 14:17:50 -0000 1.61.2.38 +++ openacs-4/packages/acs-tcl/tcl/tcl-documentation-procs.tcl 13 Feb 2024 16:48:52 -0000 1.61.2.39 @@ -1294,49 +1294,74 @@ if { [ad_complaints_count] > 0 } { - # - # Add safety belt to prevent recursive loop - # - if {[incr ::__ad_complain_depth] < 10} { + set complaints [ad_complaints_get_list] + if {$warn_p} { + ad_log warning "contract in '$::ad_page_contract_context'"\ + "was violated:\n" [join $complaints "\n "] + } - set complaints [ad_complaints_get_list] - if {$warn_p} { - ad_log warning "contract in '$::ad_page_contract_context'"\ - "was violated:\n" [join $complaints "\n "] + if { [info exists return_errors] } { + upvar 1 $return_errors error_list + set error_list $complaints + } else { + template::multirow create complaints text + foreach elm $complaints { + template::multirow append complaints $elm } - - if { [info exists return_errors] } { - upvar 1 $return_errors error_list - set error_list $complaints - } else { - template::multirow create complaints text - foreach elm $complaints { - template::multirow append complaints $elm - } - ad_try { + ad_try { + if {[incr ::__ad_complain_depth] == 1} { + # + # Render the error page going through templating, + # theming and so on. + # + # This is the intended complaint behavior, where + # the page will look "fancy" and consistent with + # the rest of the website. + # set html [ad_parse_template \ -params [list complaints [list context $::ad_page_contract_context] \ [list prev_url [util::get_referrer -trusted]] \ ] [template::themed_template "/packages/acs-tcl/lib/complain"]] - } on error {errorMsg} { - set errorCode $::errorCode + } else { # - # Check, if we were called from "ad_script_abort" (intentional abortion) + # We detected a recursion. This can happen if the + # templates involved in rendering the complaint + # also fail their own validation. # - if {[ad_exception $errorCode] eq "ad_script_abort"} { - # - # Yes, this was an intentional abortion - # - return "" - } - ad_log error "problem rendering complain page: $errorMsg ($errorCode) $::errorInfo" - set html "Invalid input" + # We fallback to a basic rendering that won't + # involve any other template in order to break the + # cycle. + # + ad_log Warning "Depth of recursive complaints exceeded. We will return a basic rendering." + set html [subst { + + + [_ acs-tcl.lt_Problem_with_your_inp] + + + + + + }] } - ns_return 422 text/html $html - ad_script_abort + } on error {errorMsg} { + set errorCode $::errorCode + # + # Check, if we were called from "ad_script_abort" (intentional abortion) + # + if {[ad_exception $errorCode] eq "ad_script_abort"} { + # + # Yes, this was an intentional abortion + # + return "" + } + ad_log error "problem rendering complain page: $errorMsg ($errorCode) $::errorInfo" + set html "Invalid input" } - } else { - ns_log Warning "ad_page_contract: depth of recursive complaints exceeded, complaint ignored" + ns_return 422 text/html $html + ad_script_abort } } }