From 559fed5ba9dc59d082287494f9b3d4e154bbf331 Mon Sep 17 00:00:00 2001
From: Lorenz Wildberg <lorenz@wild-fisch.de>
Date: Sun, 24 Sep 2023 19:30:13 +0200
Subject: [PATCH] glib-2.0: Add new symbols from 2.78

---
 vapi/glib-2.0.vapi | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/vapi/glib-2.0.vapi b/vapi/glib-2.0.vapi
index 55f1a7b2c..ee14f186a 100644
--- a/vapi/glib-2.0.vapi
+++ b/vapi/glib-2.0.vapi
@@ -1328,6 +1328,9 @@ public class string {
 	public string make_valid (ssize_t len = -1);
 	[CCode (cname = "g_utf8_normalize")]
 	public string normalize (ssize_t len = -1, GLib.NormalizeMode mode = GLib.NormalizeMode.DEFAULT);
+	[Version (since = "2.78")]
+	[CCode (cname = "g_utf8_truncate_middle")]
+	public string truncate_middle (size_t truncate_length);
 
 	[CCode (cname = "g_utf8_strup")]
 	public string up (ssize_t len = -1);
@@ -2045,6 +2048,8 @@ namespace GLib {
 		public static uint add_seconds (uint interval, owned SourceFunc function, [CCode (pos = 0.1)] int priority = Priority.DEFAULT);
 		[Version (since = "2.14")]
 		public static uint add_seconds_full (int priority, uint interval, owned SourceFunc function);
+		[Version (since = "2.78")]
+		public static uint add_seconds_once (uint interval, SourceOnceFunc function);
 	}
 
 	[CCode (cname = "GSource")]
@@ -5056,6 +5061,8 @@ namespace GLib {
 		public static double rand_double_range (double begin, double end);
 		[Version (since = "2.22")]
 		public static void log_set_fatal_handler (LogFatalFunc log_func);
+		[Version (since = "2.78")]
+		public static void disable_crash_reporting ();
 
 		public delegate bool LogFatalFunc (string? log_domain, LogLevelFlags log_levels, string message);
 	}
@@ -5714,8 +5721,13 @@ namespace GLib {
 	[CCode (cname = "GString", cprefix = "g_string_", free_function = "g_string_free", type_id = "G_TYPE_GSTRING")]
 	public class StringBuilder {
 		public StringBuilder (string init = "");
+		[CCode (cname = "g_string_new_len")]
+		public StringBuilder.from_buffer ([CCode (array_length_type = "gssize")] char[] init);
 		[CCode (cname = "g_string_sized_new")]
 		public StringBuilder.sized (size_t dfl_size);
+		[Version (since = "2.78")]
+		[CCode (cname = "g_string_new_take")]
+		public StringBuilder.take (owned string init);
 		public unowned StringBuilder assign (string rval);
 		public unowned StringBuilder append (string val);
 		public unowned StringBuilder append_c (char c);
@@ -6368,6 +6380,7 @@ namespace GLib {
 		public const uint @2_72;
 		public const uint @2_74;
 		public const uint @2_76;
+		public const uint @2_78;
 
 		[CCode (cname = "glib_binary_age")]
 		public const uint binary_age;
-- 
GitLab

diff --git a/vala/valamarkupreader.vala b/vala/valamarkupreader.vala
index 3ad25e045..6a290eb95 100644
--- a/vala/valamarkupreader.vala
+++ b/vala/valamarkupreader.vala
@@ -239,32 +239,34 @@ public class Vala.MarkupReader {
 				Report.error (null, "invalid UTF-8 character");
 			} else if (u == '&') {
 				char* next_pos = current + u.to_utf8 (null);
-				if (((string) next_pos).has_prefix ("amp;")) {
+				char buffer[16];
+				Memory.copy (buffer, next_pos, (end - next_pos >= buffer.length ? buffer.length - 1 : end - next_pos));
+				if (((string) buffer).has_prefix ("amp;")) {
 					content.append (((string) text_begin).substring (0, (int) (current - text_begin)));
 					content.append_c ('&');
 					current += 5;
 					text_begin = current;
-				} else if (((string) next_pos).has_prefix ("quot;")) {
+				} else if (((string) buffer).has_prefix ("quot;")) {
 					content.append (((string) text_begin).substring (0, (int) (current - text_begin)));
 					content.append_c ('"');
 					current += 6;
 					text_begin = current;
-				} else if (((string) next_pos).has_prefix ("apos;")) {
+				} else if (((string) buffer).has_prefix ("apos;")) {
 					content.append (((string) text_begin).substring (0, (int) (current - text_begin)));
 					content.append_c ('\'');
 					current += 6;
 					text_begin = current;
-				} else if (((string) next_pos).has_prefix ("lt;")) {
+				} else if (((string) buffer).has_prefix ("lt;")) {
 					content.append (((string) text_begin).substring (0, (int) (current - text_begin)));
 					content.append_c ('<');
 					current += 4;
 					text_begin = current;
-				} else if (((string) next_pos).has_prefix ("gt;")) {
+				} else if (((string) buffer).has_prefix ("gt;")) {
 					content.append (((string) text_begin).substring (0, (int) (current - text_begin)));
 					content.append_c ('>');
 					current += 4;
 					text_begin = current;
-				} else if (((string) next_pos).has_prefix ("percnt;")) {
+				} else if (((string) buffer).has_prefix ("percnt;")) {
 					content.append (((string) text_begin).substring (0, (int) (current - text_begin)));
 					content.append_c ('%');
 					current += 8;
