X-Git-Url: https://git.llucax.com/mecon/scripts.git/blobdiff_plain/6434bbcca8a2c04d22a44f2399eb0f1584f6c343..14c8fa85f48e3f3f15b2e6503d757c9b0f66da8b:/code2xmi/code2xmi.php?ds=sidebyside diff --git a/code2xmi/code2xmi.php b/code2xmi/code2xmi.php index 0fb2ea7..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); + $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; }