[cig-commits] commit: Fix escaping of > and &

Mercurial hg at geodynamics.org
Mon Jul 30 00:12:15 PDT 2012


changeset:   460:3413d8547d85
tag:         tip
user:        Walter Landry <wlandry at caltech.edu>
date:        Mon Jul 30 00:11:57 2012 -0700
files:       json_parser/print_xml.cxx
description:
Fix escaping of > and &


diff -r 0854feb1a79c -r 3413d8547d85 json_parser/print_xml.cxx
--- a/json_parser/print_xml.cxx	Mon Jul 09 16:43:41 2012 -0700
+++ b/json_parser/print_xml.cxx	Mon Jul 30 00:11:57 2012 -0700
@@ -14,11 +14,17 @@ std::string fix_comparisons(const std::s
       result.replace(i,1,"&lt;");
       i=result.find('<',i+1);
     }
-  i=result.find('<');
+  i=result.find('>');
   while(i!=std::string::npos)
     {
       result.replace(i,1,"&gt;");
       i=result.find('>',i+1);
+    }
+  i=result.find('&');
+  while(i!=std::string::npos)
+    {
+      result.replace(i,1,"&amp;");
+      i=result.find('&',i+1);
     }
   return result;
 }



More information about the CIG-COMMITS mailing list