[network-manager-openvpn/th/import-cleanup-bgo760987: 2/7] properties: skip over UTF-8 BOM



commit e5de0b3c0218629b7b1b01a4d9d958a24f00a755
Author: Thomas Haller <thaller redhat com>
Date:   Fri Jan 22 14:41:24 2016 +0100

    properties: skip over UTF-8 BOM
    
    Drop the UTF-8 BOM as done by openvpn:
      
https://github.com/OpenVPN/openvpn/blob/417fe4a72c82accca8d95fb0488427f5b6dc4157/src/openvpn/options.c#L3855

 properties/import-export.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
---
diff --git a/properties/import-export.c b/properties/import-export.c
index 1db45fa..5e885ef 100644
--- a/properties/import-export.c
+++ b/properties/import-export.c
@@ -553,6 +553,12 @@ do_import (const char *path, const char *contents, gsize contents_len, GError **
                }
        }
 
+       if (strncmp (contents, "\xEF\xBB\xBF", 3) == 0) {
+               /* skip over UTF-8 BOM */
+               contents += 3;
+               contents_len -= 3;
+       }
+
        lines = g_strsplit_set (contents, "\r\n", 0);
        if (g_strv_length (lines) <= 1) {
                g_set_error_literal (error,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]