[network-manager-openvpn: 4/10] properties: skip over UTF-8 BOM



commit ea0c4d9e2f5571eb1c57a24f2a0b47b896b0e9ee
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 b25e6e2..797463d 100644
--- a/properties/import-export.c
+++ b/properties/import-export.c
@@ -568,6 +568,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]