Skip to content
This repository has been archived by the owner on Nov 6, 2023. It is now read-only.

Commit

Permalink
sanitize fields in mapjs
Browse files Browse the repository at this point in the history
  • Loading branch information
evanwill committed Mar 17, 2020
1 parent 04744c2 commit e61d01f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions _includes/js/map-js.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
{% for item in items %}
{ "type":"Feature", "geometry":{ "type":"Point", "coordinates":[{{ item.longitude | strip }},{{ item.latitude | strip }}] }, "properties":
{ "title": {{ item.title | escape | jsonify }},
{% for f in fields %}"{{ f.field | escape }}": {{ item[f.field] | escape | jsonify }},{% endfor %} "cdm": {{ item.cdmid | jsonify }}, {% if item.youtubeid %} "youtube": {{ item.youtubeid | jsonify }},{% endif %} "id": {{ item.objectid | jsonify }} } }{% unless forloop.last %}, {% endunless %}{% endfor %}
{% for f in fields %}{{ f.field | escape | jsonify }}: {{ item[f.field] | escape | jsonify }},{% endfor %} "cdm": {{ item.cdmid | jsonify }}, {% if item.youtubeid %} "youtube": {{ item.youtubeid | jsonify }},{% endif %} "id": {{ item.objectid | jsonify }} } }{% unless forloop.last %}, {% endunless %}{% endfor %}
]};

/* init map and set zoom */
Expand Down Expand Up @@ -79,8 +79,8 @@
feature.properties.title + '</a></h4><div class="text-center"><a class="btn btn-light" href="' + itemHref +
'" ><img class="mapthumb" src="' + thumbSrc + '" alt="item thumbnail"></a></div><p class="mt-0">';
{% for f in fields %}{% if f.display_name %}
if (feature.properties.{{ f.field }}) {
popupTemplate += '<strong>{{ f.display_name }}:</strong> ' + feature.properties.{{ f.field }} + '<br>';
if (feature.properties[{{ f.field | escape | jsonify }}]) {
popupTemplate += '<strong>{{ f.display_name }}:</strong> ' + feature.properties[{{ f.field | escape | jsonify }}] + '<br>';
}
{% endif %}{% endfor %}
popupTemplate += '</p><div class="text-center"><a class="btn btn-light" href="' + itemHref + '" >View Item</a></div>';
Expand Down

0 comments on commit e61d01f

Please sign in to comment.