From: Daira Hopwood Date: Thu, 5 Sep 2013 17:08:34 +0000 (+0100) Subject: Mon Aug 8 19:02:04 BST 2011 david-sarah@jacaranda.org X-Git-Url: https://git.rkrishnan.org/%5B/%5D%20/uri/frontends/wapi.txt?a=commitdiff_plain;h=a0dbf38c6d104636d3b9cf970c6e03843975b6c8;p=tahoe-lafs%2Ftahoe-lafs.git Mon Aug 8 19:02:04 BST 2011 david-sarah@jacaranda.org * node.py: tolerate a UTF-8 BOM at the start of tahoe.cfg. fixes #1470 --- diff --git a/src/allmydata/node.py b/src/allmydata/node.py index 38cffe54..1fda6f0a 100644 --- a/src/allmydata/node.py +++ b/src/allmydata/node.py @@ -119,7 +119,21 @@ class Node(service.MultiService): def read_config(self): self.error_about_old_config_files() self.config = ConfigParser.SafeConfigParser() - self.config.read([os.path.join(self.basedir, "tahoe.cfg")]) + + tahoe_cfg = os.path.join(self.basedir, "tahoe.cfg") + try: + f = open(tahoe_cfg, "rb") + try: + # Skip any initial Byte Order Mark. Since this is an ordinary file, we + # don't need to handle incomplete reads, and can assume seekability. + if f.read(3) != '\xEF\xBB\xBF': + f.seek(0) + self.config.readfp(f) + finally: + f.close() + except EnvironmentError: + if os.path.exists(tahoe_cfg): + raise cfg_tubport = self.get_config("node", "tub.port", "") if not cfg_tubport: