X-Git-Url: https://git.llucax.com/mecon/scripts.git/blobdiff_plain/0535486f276ca3c56cea35af4860af084a8dae1c..cba4ec1c8ae5acc82e95cd512170ba76a7b66df6:/code2xmi/code2xmi.php diff --git a/code2xmi/code2xmi.php b/code2xmi/code2xmi.php index 08a869c..b123a23 100755 --- a/code2xmi/code2xmi.php +++ b/code2xmi/code2xmi.php @@ -1,4 +1,4 @@ -#! /usr/bin/php4 -qC +#!/usr/bin/php4 -qC $Id$ -----------------------------------------------------------------------------*/ +// CONVERTS A STRING TO XML ENTITIES {{{ +function xmlentities($s) { + return str_replace( + array('&', '"', '<', '>'), + array('&', '"', '<', '>'), + $s); +} +// }}} + //TAG's XML {{{ $xmi_start = << @@ -127,7 +136,7 @@ for ($j = 1; $j < count($argv); $j++) { $options['type'] = $type; //If there is more documentation, I add it to the main documentation if (trim($rest)) { - $options['documentation'].= "Returns: ".trim($rest)."\n"; + $options['documentation'].= "Returns: ".xmlentities(trim($rest))."\n"; } $doc_param = 0; $rest = ''; @@ -141,14 +150,12 @@ for ($j = 1; $j < count($argv); $j++) { $rest = substr($rest, strpos($rest,' ') + 1); } $options['param'][$cont_param]['type'] = $type; - $options['param'][$cont_param]['documentation'] = trim(substr(trim($rest), strpos(trim($rest), ' '))); + $options['param'][$cont_param]['documentation'] = + xmlentities(trim(substr(trim($rest), strpos(trim($rest), ' ')))); $doc_param = 1; break; default: - $tmp2 = str_replace('"', '"', $tmp2); - $tmp2 = str_replace('<', '<' , $tmp2); - $tmp2 = str_replace('>', '>' , $tmp2); - $tmp2 = str_replace('&', '&' , $tmp2); + $tmp2 = xmlentities($tmp2); if (@$doc_param) { $options['param'][$cont_param]['documentation'].= "\n".$tmp2; }