Skip to content

Commit

Permalink
Use xml.sax.saxutils escape instead of one from generateds
Browse files Browse the repository at this point in the history
Change-Id: I29d6d7191492e84650df3a3c95e127fc6beb1097
Partial-Bug: #1394044
(cherry picked from commit 0c06395)
  • Loading branch information
Hampapur Ajay committed Dec 3, 2014
1 parent 75a5b52 commit d071e19
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion ifmap_frontend.py
Expand Up @@ -2388,6 +2388,7 @@ def _generate_ifmap_db_impl(self, gen_fname, gen_type_pfx):
write(gen_file, "import cStringIO")
write(gen_file, "from lxml import etree")
write(gen_file, "")
write(gen_file, "from xml.sax.saxutils import escape")
write(gen_file, "from cfgm_common.ifmap.client import client, namespaces")
write(gen_file, "from cfgm_common.ifmap.request import NewSessionRequest, RenewSessionRequest")
write(gen_file, "from cfgm_common.ifmap.request import EndSessionRequest, PublishRequest")
Expand Down Expand Up @@ -2455,7 +2456,8 @@ def _generate_ifmap_db_impl(self, gen_fname, gen_type_pfx):
write(gen_file, " if field is not None:")
if not prop.getCType():
# simple type
write(gen_file, " meta = Metadata('%s' , str(obj_dict['%s'])," %(prop_name, prop_field))
write(gen_file, " norm_str = escape(str(obj_dict['%s']))" %(prop_field))
write(gen_file, " meta = Metadata('%s', norm_str," %(prop_name))
write(gen_file, " {'ifmap-cardinality':'singleValue'}, ns_prefix = 'contrail')")
else: # it is complex type, use TypeGenerator's class
export_args = "buf, level = 1, name_ = '%s', pretty_print = False" %(prop_name)
Expand Down Expand Up @@ -2907,6 +2909,10 @@ def _generate_ifmap_db_impl(self, gen_fname, gen_type_pfx):
write(gen_file, " else: # parent is config-root")
write(gen_file, " parent_imid = '%s'" %(_BASE_PARENT_IMID))
write(gen_file, "")
write(gen_file, " # Normalize/escape special chars")
write(gen_file, " my_imid = escape(my_imid)")
write(gen_file, " parent_imid = escape(parent_imid)")
write(gen_file, "")
write(gen_file, " return (my_imid, parent_imid)")
write(gen_file, " #end %s_alloc_ifmap_id" %(method_name))
write(gen_file, "")
Expand Down

0 comments on commit d071e19

Please sign in to comment.