Fix three bugs found reviewing this session's changes
- notes.js's ICON_LABELS wasn't extended for the shop_supermarket/ shop_convenience keys icons.js added — the note icon picker showed the raw internal key as the title instead of a real label. - Plugins.run mislabeled a malformed plugin.json as "plugin did not print valid JSON" — a message written for bad script stdout, not a bad manifest, since both paths shared one rescue. - overpass_pois.rb's description_for joined raw OSM tag values with "\n" — an operator/opening_hours tag with an embedded newline could inject an extra line into the popup that gpx.js's formatDescription (built for p4n2gpx's own well-formed lines) would render as its own independent, legitimate-looking link. Tag values are stripped of embedded newlines before joining.
This commit is contained in:
1 parent
7c664578af
commit
ea9cd5fc40
5 files changed
+48
-3
No files matched your search
@@ -106,11 +106,22 @@ module Maptool
|
||||
private_class_method :category_for
|
||||
|
||||
def self.description_for(tags)
|
||||
lines = DESCRIPTION_TAGS.filter_map { |tag, label| "#{label}: #{tags[tag]}" if tags[tag] }
|
||||
lines = DESCRIPTION_TAGS.filter_map { |tag, label| "#{label}: #{clean_tag(tags[tag])}" if tags[tag] }
|
||||
website = tags["website"] || tags["contact:website"]
|
||||
lines << website if website
|
||||
lines << clean_tag(website) if website
|
||||
lines.empty? ? nil : lines.join("\n")
|
||||
end
|
||||
private_class_method :description_for
|
||||
|
||||
# An OSM tag value is free text from a world-editable map — an embedded
|
||||
# newline could otherwise inject an extra "line" of its own into the
|
||||
# description, e.g. an operator tag ending in "\nhttps://evil.example"
|
||||
# would render as its own separate, legitimate-looking link line once
|
||||
# gpx.js's formatDescription (written for p4n2gpx's own well-formed
|
||||
# "Label: value" lines) splits on "\n".
|
||||
def self.clean_tag(value)
|
||||
value.to_s.tr("\n\r", " ").strip
|
||||
end
|
||||
private_class_method :clean_tag
|
||||
end
|
||||
end
|
||||
@@ -55,7 +55,11 @@ module Maptool
|
||||
|
||||
manifest_path = File.join(plugin_dir, "plugin.json")
|
||||
|
||||
command = JSON.parse(File.read(manifest_path))["command"]
|
||||
command = begin
|
||||
JSON.parse(File.read(manifest_path))["command"]
|
||||
rescue JSON::ParserError
|
||||
raise RunError, "plugin has an invalid plugin.json"
|
||||
end
|
||||
raise RunError, "plugin has no command" unless command
|
||||
|
||||
south, west, north, east = bbox
|
||||
|
||||
Reference in new issue
Block a user