diff --git a/inc/confutils.php b/inc/confutils.php
index edea800924578bc92ade1ab918c85ede7c9faf24..404cc6050dff8c4cc5406d5a8044935ea7aadbad 100644
--- a/inc/confutils.php
+++ b/inc/confutils.php
@@ -143,6 +143,9 @@ function getSchemes() {
  */
 function linesToHash($lines, $lower=false) {
     $conf = array();
+    // remove BOM
+    if (isset($lines[0]) && substr($lines[0],0,3) == pack('CCC',0xef,0xbb,0xbf))
+        $lines[0] = substr($lines[0],3);
     foreach ( $lines as $line ) {
         //ignore comments (except escaped ones)
         $line = preg_replace('/(?<![&\\\\])#.*$/','',$line);