Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove BOM #60

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
4 changes: 4 additions & 0 deletions jip/maven.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#! /usr/bin/env jython
# -
# Copyright (C) 2011 Sun Ning<[email protected]>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
Expand Down Expand Up @@ -110,6 +111,9 @@ def get_element_tree(self):
## we use this dirty method to remove namesapce attribute so that elementtree will use default empty namespace
pom_string = re.sub(r"<project(.|\s)*?>", '<project>', self.pom_string, 1)
parser = ElementTree.XMLParser(target=WhitespaceNormalizer())
# Remove BOM, or a Byte Order Mark. http://en.wikipedia.org/wiki/Byte_order_mark
first_tag_position = pom_string.encode().decode('utf-8').find('<')
pom_string = pom_string[first_tag_position:]
parser.feed(pom_string.encode('utf-8'))
self.eletree = parser.close()
return self.eletree
Expand Down