Index: openacs-4/packages/acs-tcl/tcl/text-html-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/text-html-procs.tcl,v
diff -u -r1.53 -r1.53.2.1
--- openacs-4/packages/acs-tcl/tcl/text-html-procs.tcl 27 Sep 2007 08:02:51 -0000 1.53
+++ openacs-4/packages/acs-tcl/tcl/text-html-procs.tcl 18 Apr 2008 03:40:16 -0000 1.53.2.1
@@ -1329,6 +1329,21 @@
#
####################
+ad_proc -public ad_html_text_convertable_p {
+ -from
+ -to
+} {
+ Returns true of ad_html_text_convert can handle the given from and to mime types.
+} {
+ set valid_froms { text/enhanced text/plain text/fixed-width text/html text/xml }
+ set valid_tos { text/plain text/html }
+ # Validate procedure input
+ set from [ad_decode $from "html" "text/html" "text" "text/plain" "plain" "text/plain" $from]
+ set to [ad_decode $to "html" "text/html" "text" "text/plain" "plain" "text/plain" $to]
+ return [expr {[lsearch $valid_froms $from] != -1 &&
+ [lsearch $valid_tos $to] != -1}]
+}
+
ad_proc -public ad_html_text_convert {
{-from text/plain}
{-to text/html}
@@ -1401,21 +1416,11 @@
if { $text eq "" } {
return ""
}
-
- set valid_froms { text/enhanced text/plain text/fixed-width text/html text/xml }
- set valid_tos { text/plain text/html }
- # Validate procedure input
- set from [ad_decode $from "html" "text/html" "text" "text/plain" "plain" "text/plain" $from]
- if { [lsearch $valid_froms $from] == -1 } {
- error "Unknown text input format, '$from'. Valid formats are $valid_froms."
+ if { ![ad_html_text_convertable_p -from $from -to $to] } {
+ error "Illegal mime types for conversion - from: $from to: $to"
}
- set to [ad_decode $to "html" "text/html" "text" "text/plain" "plain" "text/plain" $to]
- if { [lsearch $valid_tos $to] == -1 } {
- error "Unknown text input format, '$to'. Valid formats are $valid_tos."
- }
-
# Do the conversion
switch $from {
text/enhanced {