Jason, what version of openacs are you using? what version of tcl?
try the following in the shell:
set var x
set val 123
ad_page_contract_filter_proc_integer var val
(this is a valid test and returns 1) and then
set var x
set val [ns_urldecode 1017%3C/p%3E%0D%0A%3Cp%3E]
ad_page_contract_filter_proc_integer var val
(this is the test with the invalid id from your example)
If the integer test is the problem, the second one crashes.
the second call should return 0.
for me, this works nicely...