From e1a88e96883e7209f7f0d954cb78ed2f6d63f347 Mon Sep 17 00:00:00 2001 From: mitchell <70453897+667e-11@users.noreply.github.com> Date: Thu, 6 Sep 2018 22:33:50 -0400 Subject: Fixed potential crash with non-UTF-8 bytes copy-pasted into non-UTF-8 buffer. GTK appears to aggressively convert clipboard text to/from UTF-8, even if it cannot be converted. Try to handle it like Scintilla does by falling back on ISO-8859-1. --- modules/textadept/editing.lua | 1 + 1 file changed, 1 insertion(+) (limited to 'modules/textadept/editing.lua') diff --git a/modules/textadept/editing.lua b/modules/textadept/editing.lua index 9235aa70..27af2eca 100644 --- a/modules/textadept/editing.lua +++ b/modules/textadept/editing.lua @@ -242,6 +242,7 @@ function M.paste() end -- Strip leading indentation from clipboard text. local text = ui.clipboard_text + if not buffer.encoding then text = text:iconv('ISO-8859-1', 'UTF-8') end local lead = text:match('^[ \t]*') if lead ~= '' then text = text:sub(#lead + 1):gsub('\n'..lead, '\n') end -- Change indentation to match buffer indentation settings. -- cgit v1.2.3