[Asterisk-code-review] config.c: Skip UTF-8 BOMs if present when reading config files (asterisk[17])
George Joseph
asteriskteam at digium.com
Fri Dec 27 13:12:54 CST 2019
George Joseph has submitted this change. ( https://gerrit.asterisk.org/c/asterisk/+/13488 )
Change subject: config.c: Skip UTF-8 BOMs if present when reading config files
......................................................................
config.c: Skip UTF-8 BOMs if present when reading config files
ASTERISK-28667 #close
Change-Id: I4767ed365c98f3e1587b7653321048a31d8a53b2
---
M main/config.c
1 file changed, 12 insertions(+), 0 deletions(-)
Approvals:
Kevin Harwell: Looks good to me, but someone else must approve
Joshua C. Colp: Looks good to me, but someone else must approve
George Joseph: Looks good to me, approved; Approved for Submit
diff --git a/main/config.c b/main/config.c
index 002ae2f..d5dd93c 100644
--- a/main/config.c
+++ b/main/config.c
@@ -2219,6 +2219,18 @@
continue;
}
+ /* If there is a UTF-8 BOM, skip over it */
+ if (lineno == 1) {
+#define UTF8_BOM "\xEF\xBB\xBF"
+ size_t line_bytes = strlen(buf);
+ size_t bom_bytes = sizeof(UTF8_BOM) - 1;
+ if (line_bytes >= bom_bytes
+ && !memcmp(buf, UTF8_BOM, bom_bytes)) {
+ memmove(buf, &buf[bom_bytes], line_bytes - bom_bytes + 1);
+ }
+#undef UTF8_BOM
+ }
+
if (ast_test_flag(&flags, CONFIG_FLAG_WITHCOMMENTS)
&& lline_buffer
&& ast_str_strlen(lline_buffer)) {
--
To view, visit https://gerrit.asterisk.org/c/asterisk/+/13488
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings
Gerrit-Project: asterisk
Gerrit-Branch: 17
Gerrit-Change-Id: I4767ed365c98f3e1587b7653321048a31d8a53b2
Gerrit-Change-Number: 13488
Gerrit-PatchSet: 2
Gerrit-Owner: Sean Bright <sean.bright at gmail.com>
Gerrit-Reviewer: Friendly Automation
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Joshua C. Colp <jcolp at sangoma.com>
Gerrit-Reviewer: Kevin Harwell <kharwell at digium.com>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20191227/cfa4ddfa/attachment.html>
More information about the asterisk-code-review
mailing list