Merge "Fix Spark installation fails when parsing spark-env.sh" into stable/liberty

This commit is contained in:
Jenkins 2015-11-24 14:08:39 +00:00 committed by Gerrit Code Review
commit fce47d13d3
2 changed files with 14 additions and 1 deletions

View File

@ -0,0 +1,3 @@
---
fixes:
- Escape unhandled unicode characters in environment configuration files

View File

@ -143,7 +143,7 @@ class EnvironmentConfig(BaseConfigurationFile):
def parse(self, content):
for line in content.splitlines():
line = six.text_type(line.strip())
line = self._escape(line)
match = self._regex.match(line)
if match:
name, value = match.groups()
@ -153,6 +153,16 @@ class EnvironmentConfig(BaseConfigurationFile):
else:
self._lines.append(line)
@staticmethod
def _escape(string):
try:
string = string.decode("utf-8")
except AttributeError:
pass
string = six.text_type(string).strip()
string = string.replace("\"", "")
return string
def render(self):
result = []
for line in self._lines: