@@ -177,12 +177,12 @@ function parseAIML($fn,$aimlContent, $from_zip = false)
177177 $ pattern = str_replace ("' " , ' ' , $ pattern );
178178 $ that = $ category ->that ;
179179 $ template = $ category ->template ->asXML ();
180- $ template = str_replace ( '<template> ' , '' , $ template );
181- $ template = str_replace ( ' </ template> ' , '' , $ template );
182- $ aiml_add = str_replace ( "\r\n" , '' , $ fullCategory );
183- # Strip CRLF from category (windows)
184- $ aiml_add = str_replace ( "\n" , '' , $ aiml_add );
185- # Strip LF from category (mac/*nix)
180+ $ template = ltrim ( $ template , '<template> ' );
181+ $ template = ltrim ( $ template, "\r\n " );
182+ $ template = rtrim ( $ template , ' </template> ' );
183+ $ template = rtrim ( $ template , "\r\n" );
184+ # Strip CRLF and LF from category (Windows/mac/*nix)
185+ $ aiml_add = str_replace ( array ( "\r\n" , "\n" ), '' , $ fullCategory );
186186 $ sql_add = str_replace ('[aiml_add] ' , mysql_real_escape_string ($ aiml_add ), $ sql_template );
187187 $ sql_add = str_replace ('[pattern] ' , $ pattern , $ sql_add );
188188 $ sql_add = str_replace ('[that] ' , $ that , $ sql_add );
0 commit comments