소스 검색

wxGUI/gmodeler: escaping (all) characters for XML using Python saxutils (fixes https://trac.osgeo.org/grass/ticket/1791)

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@58371 15284696-431f-4ddb-bdfa-cd5b030d7da7
Vaclav Petras 11 년 전
부모
커밋
a15a3a4803
1개의 변경된 파일8개의 추가작업 그리고 4개의 파일을 삭제
  1. 8 4
      gui/wxpython/gmodeler/model.py

+ 8 - 4
gui/wxpython/gmodeler/model.py

@@ -36,6 +36,8 @@ try:
 except ImportError:
     import elementtree.ElementTree as etree # Python <= 2.4
 
+import xml.sax.saxutils as saxutils
+
 import wx
 from wx.lib import ogl
 
@@ -1817,10 +1819,12 @@ class WriteModelFile:
         self._footer()
 
     def _filterValue(self, value):
-        """!Make value XML-valid"""
-        value = value.replace('<', '&lt;')
-        value = value.replace('>', '&gt;')
-        
+        """!Escapes value to be stored in XML.
+
+        @param value string to be escaped as XML
+        @returns a XML-valid string
+        """
+        value = saxutils.escape(value)
         return value
         
     def _header(self):