sorry team, typo in $SUBJ, will send v2
2016-03-11 11:20 GMT+01:00 Jiri Prochazka <jprochaz(a)redhat.com>:
> Current lxml.etree.parse implementation allows using HTTP, but not
> HTTPS. When user tries to use HTTPS URL, it crashes on IOException.
>
> This patch fixes that by checking if the URL starts with HTTPS
> and uses urlopen to open the HTTPS page. This allows lxml.etree.parse
> method to parse the XML from the HTTPS URL.
>
> urllib2 is already used Common/Path and is available since Python2.6
> so no new dependency is added.
>
> Signed-off-by: Jiri Prochazka <jprochaz(a)redhat.com>
> ---
> lnst/Controller/XmlParser.py | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/lnst/Controller/XmlParser.py b/lnst/Controller/XmlParser.py
> index afc2cda..355b5e8 100644
> --- a/lnst/Controller/XmlParser.py
> +++ b/lnst/Controller/XmlParser.py
> @@ -15,6 +15,7 @@ import re
> import sys
> import copy
> from lxml import etree
> +from urllib2 import urlopen
> from lnst.Common.Config import lnst_config
> from lnst.Controller.XmlTemplates import XmlTemplates
> from lnst.Controller.XmlProcessing import XmlProcessingError
> @@ -79,7 +80,10 @@ class XmlParser(object):
>
> def _parse(self, path):
> try:
> - doc = etree.parse(path)
> + if path.startswith('https'):
> + doc = etree.parse(urlopen(path))
> + else:
> + doc = etree.parse(path)
> except etree.LxmlError as err:
> # A workaround for cases when lxml (quite strangely)
> # sets the filename to <string>.
> --
> 2.4.3
>