aboutsummaryrefslogtreecommitdiff
path: root/modules/textadept/editing.lua
diff options
context:
space:
mode:
authormitchell <70453897+667e-11@users.noreply.github.com>2018-09-06 22:33:50 -0400
committermitchell <70453897+667e-11@users.noreply.github.com>2018-09-06 22:33:50 -0400
commite1a88e96883e7209f7f0d954cb78ed2f6d63f347 (patch)
treebba07ea012956a522c9659b1f527a43335ceacf4 /modules/textadept/editing.lua
parent41abf8f71f31038968fe80e020280e848d8fd82d (diff)
downloadtextadept-e1a88e96883e7209f7f0d954cb78ed2f6d63f347.tar.gz
textadept-e1a88e96883e7209f7f0d954cb78ed2f6d63f347.zip
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.
Diffstat (limited to 'modules/textadept/editing.lua')
-rw-r--r--modules/textadept/editing.lua1
1 files changed, 1 insertions, 0 deletions
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.