1
1
--[[
2
2
This file is part of darktable,
3
3
Copyright 2016 by Tobias Jakobs.
4
+ Copyright 2016 by Erik Augustin.
4
5
5
6
This program is free software: you can redistribute it and/or modify
6
7
it under the terms of the GNU General Public License as published by
@@ -157,6 +158,7 @@ function string.stripAccents( str )
157
158
end
158
159
159
160
-- Escape XML characters
161
+ -- Keep & first, otherwise it will double escape other characters
160
162
-- https://stackoverflow.com/questions/1091945/what-characters-do-i-need-to-escape-in-xml-documents
161
163
function string .escapeXmlCharacters ( str )
162
164
@@ -248,7 +250,9 @@ local function create_kml_file(storage, image_table, extra_data)
248
250
kml_file = kml_file .. " <description>Exported from darktable</description>\n "
249
251
250
252
for image ,exported_image in pairs (image_table ) do
253
+ -- Extract filename, e.g DSC9784.ARW -> DSC9784
251
254
filename = string.upper (string.gsub (image .filename ," %.%w*" , " " ))
255
+ -- Extract extension from exported image (user can choose JPG or PNG), e.g DSC9784.JPG -> .JPG
252
256
extension = string.match (exported_image ," %.%w*$" )
253
257
254
258
if ((image .longitude and image .latitude ) and
@@ -262,6 +266,7 @@ local function create_kml_file(storage, image_table, extra_data)
262
266
else
263
267
image_title = image .filename
264
268
end
269
+ -- Characters should not be escaped in CDATA, but we are using HTML fragment, so we must escape them
265
270
image_description = string .escapeXmlCharacters (image .description )
266
271
267
272
kml_file = kml_file .. " <name>" .. image_title .. " </name>\n "
0 commit comments