Bug 758687

Summary: Wild char '&' in template will cause XML parse error
Product: [Retired] CloudForms Cloud Engine Reporter: Martin Kočí <mkoci>
Component: imagefactoryAssignee: Ian McLeod <imcleod>
Status: CLOSED NOTABUG QA Contact: Martin Kočí <mkoci>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 1.0.0CC: akarol, dajohnso, deltacloud-maint, dgao, jrd, ssachdev, whayutin
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard: HUDSONdone=bug758687.py
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-01-05 19:20:12 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Bug Depends On:    
Bug Blocks: 744194    

Description Martin Kočí 2011-11-30 12:54:26 UTC
Description of problem:
If you try to build an image from command line using imagefactory and xml template with wild char '&' in raw type will cause xml parse error. 

Version-Release number of selected component (if applicable):
imagefactory-0.8.9-1.fc15.noarch
oz-0.7.9-3.fc15.noarch

How reproducible:
Always

Steps to Reproduce:
1. Create template with wild char '&' in raw type (or see attached example)
2. run #sudo imagefactory --debug --target rhevm --template /path/to/template.tdl

  
Actual results:
2011-11-30 13:47:16,814 DEBUG imgfac.ImageWarehouse.ImageWarehouse pid(17106) Message: Created Image Warehouse instance http://localhost:9090 - buckets(target_images, templates, icicles, provider_images)
2011-11-30 13:47:16,815 DEBUG imgfac.ImageWarehouse.ImageWarehouse pid(17106) Message: Created Image Warehouse instance http://localhost:9090 - buckets(target_images, templates, icicles, provider_images)
Entity: line 18: parser error : xmlParseEntityRef: no name
      Aeolus Cloud Test page on Build Created for Mumbai & Westford  Private RHE
                                                          ^
Traceback (most recent call last):
  File "/usr/bin/imagefactory", line 224, in <module>
    sys.exit(Application().main())
  File "/usr/bin/imagefactory", line 203, in main
    dispatchers = BuildDispatcher().build_image_for_targets(self.app_config['image'], None, self.app_config['template'], self.app_config['target'])
  File "/usr/lib/python2.7/site-packages/imgfac/BuildDispatcher.py", line 54, in build_image_for_targets
    image_id = self._ensure_image_with_template(image_id, template)
  File "/usr/lib/python2.7/site-packages/imgfac/BuildDispatcher.py", line 133, in _ensure_image_with_template
    name = self._xml_node(template.xml, '/template/name')
  File "/usr/lib/python2.7/site-packages/imgfac/BuildDispatcher.py", line 126, in _xml_node
    nodes = libxml2.parseDoc(xml).xpathEval(xpath)
  File "/usr/lib64/python2.7/site-packages/libxml2.py", line 1263, in parseDoc
    if ret is None:raise parserError('xmlParseDoc() failed')
libxml2.parserError: xmlParseDoc() failed


Expected results:
No xml parse error

Comment 1 wes hayutin 2012-01-03 17:41:55 UTC
adding ce-sprint-next bugs to ce-sprint

Comment 2 Ian McLeod 2012-01-05 19:20:12 UTC
TDL is an XML document standard.

A naked ampersand is not valid in XML.  It must be escaped as:

&amp;

See:

http://www.xml.com/pub/a/2001/01/31/qanda.html

Closing as NOTABUG