Changeset 3832013
- Timestamp:
- 11/28/2026 06:59:30 PM (14 hours ago)
- Location:
- leaflet-map
- Files:
-
- 20 edited
- 1 copied
-
tags/3.4.8 (copied) (copied from leaflet-map/trunk )
-
tags/3.4.8/README.md (modified) (4 diffs)
-
tags/3.4.8/class.leaflet-map.php (modified) (4 diffs)
-
tags/3.4.8/leaflet-map.php (modified) (2 diffs)
-
tags/3.4.8/readme.txt (modified) (3 diffs)
-
tags/3.4.8/scripts/construct-leaflet-map.js (modified) (5 diffs)
-
tags/3.4.8/scripts/construct-leaflet-map.min.js (modified) (1 diff)
-
tags/3.4.8/shortcodes/class.geojson-shortcode.php (modified) (4 diffs)
-
tags/3.4.8/shortcodes/class.image-overlay-shortcode.php (modified) (1 diff)
-
tags/3.4.8/shortcodes/class.wms-shortcode.php (modified) (2 diffs)
-
tags/3.4.8/templates/shortcode-helper.php (modified) (4 diffs)
-
trunk/README.md (modified) (4 diffs)
-
trunk/class.leaflet-map.php (modified) (4 diffs)
-
trunk/leaflet-map.php (modified) (2 diffs)
-
trunk/readme.txt (modified) (3 diffs)
-
trunk/scripts/construct-leaflet-map.js (modified) (5 diffs)
-
trunk/scripts/construct-leaflet-map.min.js (modified) (1 diff)
-
trunk/shortcodes/class.geojson-shortcode.php (modified) (4 diffs)
-
trunk/shortcodes/class.image-overlay-shortcode.php (modified) (1 diff)
-
trunk/shortcodes/class.wms-shortcode.php (modified) (2 diffs)
-
trunk/templates/shortcode-helper.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
leaflet-map/tags/3.4.8/README.md
r3483997 r3832013 191 191 `layer` for the layer name and `crs` for the coordination system (only supported by 192 192 leaflet: EPSG:3857 and EPSG:4326). 193 194 The default source is [NASA GIBS](https://nasa-gibs.github.io/gibs-api-docs/access-basics/), 195 using Blue Marble imagery with shaded relief and bathymetry. 196 193 197 ``` 194 198 [leaflet-wms source="https://your/wms/service?" layer="yourLayer" crs="EPSG:3857" zoom=1] … … 199 203 | Option | Default | 200 204 | ----------------- | ----------------------------------------- | 201 | `src` | https:// ows.mundialis.de/services/service? |202 | `layer ` | TOPO-OSM-WMS|205 | `src` | https://gibs.earthdata.nasa.gov/wms/epsg3857/best/wms.cgi? | 206 | `layer ` | BlueMarble_ShadedRelief_Bathymetry | 203 207 | `crs ` | EPSG:3857 | 204 208 | `zoom` | 12 | … … 211 215 | `min_zoom` | 0 | 212 216 | `max_zoom` | 20 | 213 | `attribution` | ©Leaflet ©OpenStreetMap|217 | `attribution` | NASA GIBS (for the default source and layer) | 214 218 | `lat` | 0 | 215 219 | `lng` | 0 | … … 327 331 `[leaflet-geojson]Field A = {field_a}[/leaflet-geojson]`. 328 332 333 Popup HTML in shortcode content is filtered through WordPress's `wp_kses_post()`. 334 Feature properties, including `popup_property` and table values, are displayed as text. 335 To display an image from a feature property, use a template such as 336 `[leaflet-geojson]<img src="{photo_url}" alt="{title}" width="50" height="50">[/leaflet-geojson]`. 337 Image URL substitutions accept HTTP(S) and relative URLs; event handlers are removed. 338 329 339 ### [leaflet-kml] 330 340 -
leaflet-map/tags/3.4.8/class.leaflet-map.php
r3519096 r3832013 211 211 if (defined('WP_DEBUG') && WP_DEBUG) { 212 212 $minified = ''; 213 $script_version = LEAFLET_MAP__PLUGIN_VERSION . '.' . filemtime(LEAFLET_MAP__PLUGIN_DIR . 'scripts/construct-leaflet-map.js'); 213 214 } else { 214 215 $minified = '.min'; 216 $script_version = LEAFLET_MAP__PLUGIN_VERSION; 215 217 } 216 218 … … 220 222 221 223 /* run a construct function in the document head for subsequent functions to use (it is lightweight) */ 222 wp_register_script('wp_leaflet_map', plugins_url(sprintf('scripts/construct-leaflet-map%s.js', $minified), __FILE__), Array('leaflet_js'), LEAFLET_MAP__PLUGIN_VERSION, false);224 wp_register_script('wp_leaflet_map', plugins_url(sprintf('scripts/construct-leaflet-map%s.js', $minified), __FILE__), Array('leaflet_js'), $script_version, false); 223 225 } 224 226 … … 358 360 359 361 /** 362 * Sanitize popup HTML and encode it for an inline JavaScript value. 363 * 364 * @param string $content Popup HTML. 365 * @return string JSON-encoded, sanitized HTML. 366 */ 367 public function encode_popup_html($content) 368 { 369 return wp_json_encode( 370 wp_kses_post($content), 371 JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_APOS | JSON_HEX_QUOT 372 ) ?: '""'; 373 } 374 375 /** 360 376 * Add Popups to Shapes 361 377 * … … 393 409 394 410 $message = str_replace(array("\r\n", "\n", "\r"), '<br>', $message); 395 $message = wp_kses_post( $message ); 396 $message = esc_html( $message ); 397 398 $message = "window.WPLeafletMapPlugin.unescape('{$message}')"; 411 $message = $this->encode_popup_html($message); 399 412 400 413 // use with: add_filter('leaflet_map_popup_message', 'example_callback', 10, 3); -
leaflet-map/tags/3.4.8/leaflet-map.php
r3659792 r3832013 9 9 * Text Domain: leaflet-map 10 10 * Domain Path: /languages/ 11 * Version: 3.4. 711 * Version: 3.4.8 12 12 * License: GPL2 13 13 * Leaflet Map is free software: you can redistribute it and/or modify … … 30 30 } 31 31 32 define('LEAFLET_MAP__PLUGIN_VERSION', '3.4. 7');32 define('LEAFLET_MAP__PLUGIN_VERSION', '3.4.8'); 33 33 define('LEAFLET_MAP__PLUGIN_FILE', __FILE__); 34 34 define('LEAFLET_MAP__PLUGIN_DIR', plugin_dir_path(__FILE__)); -
leaflet-map/tags/3.4.8/readme.txt
r3659792 r3832013 7 7 Tags: leaflet, map, openstreetmap, mapquest, interactive 8 8 Requires at least: 4.6 9 Tested up to: 7. 110 Version: 3.4. 711 Stable tag: 3.4. 79 Tested up to: 7.2 10 Version: 3.4.8 11 Stable tag: 3.4.8 12 12 License: GPLv2 13 13 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 120 120 121 121 Sure. Use the same attributes as leaflet-map, but use the `[leaflet-wms]` shortcode; attributes include: `src`, `layer`, and `crs`. 122 123 By default, it uses NASA GIBS Blue Marble imagery with shaded relief and bathymetry. 122 124 123 125 = Can I add a message to a marker? = … … 157 159 158 160 == Changelog == 161 162 = 3.4.8 = 163 * [Security] Fix stored cross-site scripting in shortcode popup content. 164 * [Bugfix] Replace the unavailable default WMS source with NASA GIBS Blue Marble imagery. 165 * Tested with WordPress 7.2 159 166 160 167 = 3.4.7 = -
leaflet-map/tags/3.4.8/scripts/construct-leaflet-map.js
r3043427 r3832013 177 177 }; 178 178 179 function escapeHTML(value) { 180 return String(value).replace(/[&<>"']/g, function (character) { 181 return { 182 '&': '&', 183 '<': '<', 184 '>': '>', 185 '"': '"', 186 "'": ''', 187 }[character]; 188 }); 189 } 190 191 /** Remote property HTML is data, never markup. */ 192 this.textPopup = function (value) { 193 var container = document.createElement('div'); 194 container.textContent = value == null ? '' : String(value); 195 return container; 196 }; 197 198 /** 199 * The template has already passed through wp_kses_post() in PHP. 200 * Parse it inertly, then insert feature values without parsing them as HTML. 201 */ 202 this.templatePopup = function (html, data) { 203 var template = document.createElement('template'); 204 var container = document.createElement('div'); 205 if (!('content' in template)) { 206 container.textContent = interpolate(html, data); 207 return container; 208 } 209 template.innerHTML = html; 210 211 function fill(node) { 212 if (node.nodeType === 3) { 213 node.textContent = interpolate(node.textContent, data); 214 } else if (node.nodeType === 1) { 215 // Only these attributes accept feature substitutions. In particular, 216 // never substitute into CSS, event handlers or attribute names. 217 var attributes = Array.prototype.slice.call(node.attributes); 218 for (var i = 0; i < attributes.length; i++) { 219 var attribute = attributes[i]; 220 var name = attribute.name; 221 if (attribute.value.search(templateRe) === -1) { 222 continue; 223 } 224 if (!/^(alt|title|width|height|href|src)$/.test(name)) { 225 node.removeAttribute(name); 226 continue; 227 } 228 var value = interpolate(attribute.value, data); 229 if (name === 'href' || name === 'src') { 230 // Resolve relative URLs and normalize obfuscated schemes before 231 // checking. Escaping quotes alone cannot stop javascript: URLs. 232 var url = document.createElement('a'); 233 url.href = value; 234 var allowed = 235 name === 'src' ? /^(https?:)$/i : /^(https?:|mailto:|tel:)$/i; 236 if (!allowed.test(url.protocol)) { 237 node.removeAttribute(name); 238 continue; 239 } 240 } 241 node.setAttribute(name, value); 242 } 243 } 244 for (var child = node.firstChild; child; child = child.nextSibling) { 245 fill(child); 246 } 247 } 248 249 fill(template.content); 250 container.appendChild(template.content); 251 return container; 252 }; 253 179 254 /** Adds all properties as a table-view for GeoJSON popups */ 180 255 this.propsToTable = function (props) { … … 192 267 for (var i = 0, len = keys.length; i < len; i++) { 193 268 var key = keys[i]; 194 output += '<tr><td>' + key+ '</td>';195 output += '<td>' + props[key]+ '</td></tr>';269 output += '<tr><td>' + escapeHTML(key) + '</td>'; 270 output += '<td>' + escapeHTML(props[key]) + '</td></tr>'; 196 271 } 197 272 … … 224 299 225 300 var unescape = (this.unescape = function (str) { 226 var div = document.createElement('div'); 227 div.innerHTML = str; 228 return div.innerText || str; 301 // Decode entities in template keys without parsing them as markup. 302 var textarea = document.createElement('textarea'); 303 textarea.innerHTML = str.replace(/</g, '<'); 304 return textarea.value; 229 305 }); 230 306 … … 239 315 * @param {object} data e.g. feature.properties 240 316 */ 241 this.template = function (str, data) {317 function interpolate(str, data, escapeValues) { 242 318 if (data == null) { 243 319 return str; … … 250 326 return obj.default || match; 251 327 } 252 return value;328 return escapeValues ? escapeHTML(value) : String(value); 253 329 }); 330 } 331 332 this.template = function (str, data) { 333 return interpolate(str, data, true); 254 334 }; 255 335 -
leaflet-map/tags/3.4.8/scripts/construct-leaflet-map.min.js
r3659792 r3832013 1 (function(){function y(){var m="v3.4.7";this.VERSION=m;function v(t){try{t()}catch(n){console.log("-- version --",m),console.error(n)}}var g=!1,f=[];this.push=function(t){g?v(t):f.push(t)},this.unshift=function(t){g?v(t):f.unshift(t)},this.init=function(){g=!0;for(var t=0,n=f.length;t<n;t++)v(f[t])},this.createMap=function(t){var n=document.getElementsByClassName("WPLeafletMap"),e=this.maps.length,i=n[e],r=L.map(i,t);return t.fitBounds&&(r._shouldFitBounds=!0),t.attribution&&T(t.attribution,r),this.maps.push(r),r},this.createImageMap=function(t){var n=this.createMap(t);return n.is_image_map=!0,this.images.push(n),n},this.getCurrentMap=function(){return this.maps[this.maps.length-1]},this.getCurrentGroup=function(){var t=this.maps.length;return this.markergroups[t]||(this.markergroups[t]=this.newMarkerGroup(this.maps[t-1])),this.markergroups[t]},this.getCurrentMarkerGroup=this.getCurrentGroup,this.getGroup=function(t){return new L.FeatureGroup().addTo(t)},this.newMarkerGroup=function(t){var n=this.getGroup(t);return n.timeout=null,t._shouldFitBounds&&n.on("layeradd",function(e){e.layer instanceof L.FeatureGroup&&e.layer.on("ready",function(){t.fitBounds(n.getBounds())}),window.clearTimeout(this.timeout),this.timeout=window.setTimeout(function(){try{t.fitBounds(n.getBounds())}catch{}},100)},n),n},this.propsToTable=function(t){var n,e=[];for(n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.push(n);e=e.sort();for(var i="<table>",r=0,a=e.length;r<a;r++){var o=e[r];i+="<tr><td>"+o+"</td>",i+="<td>"+t[o]+"</td></tr>"}return i+="</table>",i};function P(t){return t.trim()}function T(t,n){if(t)for(var e=t.split(";"),i=L.control.attribution({prefix:!1}).addTo(n),r=0,a=e.length;r<a;r++){var o=P(e[r]);i.addAttribution(o)}}var b=this.unescape=function(t){var n=document.createElement("div");return n.innerHTML=t,n.innerText||t},G=/\{ *(.*?) *\}/g;this.template=function(t,n){return n==null?t:t.replace(G,function(e,i){var r=E(i),a=k(n,r.key);return a??(r.default||e)})};var A=/[.‘’'“”"\[\]]+/g;function S(t){if(t==null)return[];for(var n=t.split(A),e=[],i=0,r=n.length;i<r;i++)n[i]!==""&&e.push(n[i]);return e}function k(t,n){for(var e=S(b(n)),i=t,r=0,a=e.length;r<a;r++)if(i=i[e[r]],!i)return;return i}function E(t){for(var n=t.split(" | "),e={},i=n.shift(),r=0,a=n.length;r<a;r++){var o=n[r].split(": "),h=o.shift(),s=o.join(": ")||!0;e[h]=s}return e.key=i,e}function w(t,n){typeof L<"u"&&typeof L[t]<"u"?n():setTimeout(function(){w(t,n)},100)}this.waitForSVG=function(t){w("SVGIcon",t)},this.waitForAjax=function(t){w("AjaxGeoJSON",t)},this.createScale=function(t){L.control.scale(t).addTo(this.getCurrentMap())},this.getIconOptions=function(t){for(var n=t||{},e=["iconSize","iconAnchor","shadowSize","shadowAnchor","popupAnchor","tooltipAnchor"],i=L.Icon.Default.prototype.options,r=0,a=e.length;r<a;r++){var o=e[r],h=n[o];if(h){for(var s=h.split(","),c=0,B=s.length;c<B;c++)s[c]=Number(s[c]);n[o]=s}}return n.popupAnchor||(n.popupAnchor=function(l){return l=l.slice(),l[0]=0,l[1]*=-1,l[1]-=3,l}(n.iconSize||i.iconSize)),n.iconUrl&&(n.icon=new L.Icon(n)),n},this.maps=[],this.images=[],this.markergroups={},this.markers=[],this.lines=[],this.polygons=[],this.circles=[],this.geojsons=[],this.overlays=[]}var u=window.WPLeafletMapPlugin;if(window.WPLeafletMapPlugin=new y,u){for(var p=0,M=u.length;p<M;p++)window.WPLeafletMapPlugin.push(u[p]);u.splice(0);for(var d in u)u.hasOwnProperty(d)&&(window.WPLeafletMapPlugin[d]=u[d])}window.addEventListener?window.addEventListener("load",window.WPLeafletMapPlugin.init,!1):window.attachEvent&&window.attachEvent("onload",window.WPLeafletMapPlugin.init)})();1 (function(){function S(){var T="v3.4.8";this.VERSION=T;function w(t){try{t()}catch(e){console.log("-- version --",T),console.error(e)}}var y=!1,h=[];this.push=function(t){y?w(t):h.push(t)},this.unshift=function(t){y?w(t):h.unshift(t)},this.init=function(){y=!0;for(var t=0,e=h.length;t<e;t++)w(h[t])},this.createMap=function(t){var e=document.getElementsByClassName("WPLeafletMap"),r=this.maps.length,i=e[r],n=L.map(i,t);return t.fitBounds&&(n._shouldFitBounds=!0),t.attribution&&E(t.attribution,n),this.maps.push(n),n},this.createImageMap=function(t){var e=this.createMap(t);return e.is_image_map=!0,this.images.push(e),e},this.getCurrentMap=function(){return this.maps[this.maps.length-1]},this.getCurrentGroup=function(){var t=this.maps.length;return this.markergroups[t]||(this.markergroups[t]=this.newMarkerGroup(this.maps[t-1])),this.markergroups[t]},this.getCurrentMarkerGroup=this.getCurrentGroup,this.getGroup=function(t){return new L.FeatureGroup().addTo(t)},this.newMarkerGroup=function(t){var e=this.getGroup(t);return e.timeout=null,t._shouldFitBounds&&e.on("layeradd",function(r){r.layer instanceof L.FeatureGroup&&r.layer.on("ready",function(){t.fitBounds(e.getBounds())}),window.clearTimeout(this.timeout),this.timeout=window.setTimeout(function(){try{t.fitBounds(e.getBounds())}catch{}},100)},e),e};function M(t){return String(t).replace(/[&<>"']/g,function(e){return{"&":"&","<":"<",">":">",'"':""","'":"'"}[e]})}this.textPopup=function(t){var e=document.createElement("div");return e.textContent=t==null?"":String(t),e},this.templatePopup=function(t,e){var r=document.createElement("template"),i=document.createElement("div");if(!("content"in r))return i.textContent=p(t,e),i;r.innerHTML=t;function n(o){if(o.nodeType===3)o.textContent=p(o.textContent,e);else if(o.nodeType===1)for(var a=Array.prototype.slice.call(o.attributes),c=0;c<a.length;c++){var s=a[c],u=s.name;if(s.value.search(A)!==-1){if(!/^(alt|title|width|height|href|src)$/.test(u)){o.removeAttribute(u);continue}var v=p(s.value,e);if(u==="href"||u==="src"){var l=document.createElement("a");l.href=v;var I=u==="src"?/^(https?:)$/i:/^(https?:|mailto:|tel:)$/i;if(!I.test(l.protocol)){o.removeAttribute(u);continue}}o.setAttribute(u,v)}}for(var d=o.firstChild;d;d=d.nextSibling)n(d)}return n(r.content),i.appendChild(r.content),i},this.propsToTable=function(t){var e,r=[];for(e in t)Object.prototype.hasOwnProperty.call(t,e)&&r.push(e);r=r.sort();for(var i="<table>",n=0,o=r.length;n<o;n++){var a=r[n];i+="<tr><td>"+M(a)+"</td>",i+="<td>"+M(t[a])+"</td></tr>"}return i+="</table>",i};function C(t){return t.trim()}function E(t,e){if(t)for(var r=t.split(";"),i=L.control.attribution({prefix:!1}).addTo(e),n=0,o=r.length;n<o;n++){var a=C(r[n]);i.addAttribution(a)}}var G=this.unescape=function(t){var e=document.createElement("textarea");return e.innerHTML=t.replace(/</g,"<"),e.value},A=/\{ *(.*?) *\}/g;function p(t,e,r){return e==null?t:t.replace(A,function(i,n){var o=F(n),a=B(e,o.key);return a==null?o.default||i:r?M(a):String(a)})}this.template=function(t,e){return p(t,e,!0)};var x=/[.‘’'“”"\[\]]+/g;function k(t){if(t==null)return[];for(var e=t.split(x),r=[],i=0,n=e.length;i<n;i++)e[i]!==""&&r.push(e[i]);return r}function B(t,e){for(var r=k(G(e)),i=t,n=0,o=r.length;n<o;n++)if(i=i[r[n]],!i)return;return i}function F(t){for(var e=t.split(" | "),r={},i=e.shift(),n=0,o=e.length;n<o;n++){var a=e[n].split(": "),c=a.shift(),s=a.join(": ")||!0;r[c]=s}return r.key=i,r}function P(t,e){typeof L<"u"&&typeof L[t]<"u"?e():setTimeout(function(){P(t,e)},100)}this.waitForSVG=function(t){P("SVGIcon",t)},this.waitForAjax=function(t){P("AjaxGeoJSON",t)},this.createScale=function(t){L.control.scale(t).addTo(this.getCurrentMap())},this.getIconOptions=function(t){for(var e=t||{},r=["iconSize","iconAnchor","shadowSize","shadowAnchor","popupAnchor","tooltipAnchor"],i=L.Icon.Default.prototype.options,n=0,o=r.length;n<o;n++){var a=r[n],c=e[a];if(c){for(var s=c.split(","),u=0,v=s.length;u<v;u++)s[u]=Number(s[u]);e[a]=s}}return e.popupAnchor||(e.popupAnchor=function(l){return l=l.slice(),l[0]=0,l[1]*=-1,l[1]-=3,l}(e.iconSize||i.iconSize)),e.iconUrl&&(e.icon=new L.Icon(e)),e},this.maps=[],this.images=[],this.markergroups={},this.markers=[],this.lines=[],this.polygons=[],this.circles=[],this.geojsons=[],this.overlays=[]}var f=window.WPLeafletMapPlugin;if(window.WPLeafletMapPlugin=new S,f){for(var g=0,b=f.length;g<b;g++)window.WPLeafletMapPlugin.push(f[g]);f.splice(0);for(var m in f)f.hasOwnProperty(m)&&(window.WPLeafletMapPlugin[m]=f[m])}window.addEventListener?window.addEventListener("load",window.WPLeafletMapPlugin.init,!1):window.attachEvent&&window.attachEvent("onload",window.WPLeafletMapPlugin.init)})(); -
leaflet-map/tags/3.4.8/shortcodes/class.geojson-shortcode.php
r3522877 r3832013 53 53 if ($content) { 54 54 $content = str_replace(array("\r\n", "\n", "\r"), '<br>', $content); 55 $content = htmlspecialchars($content);56 55 } 57 56 … … 68 67 $circleMarker = filter_var($circleMarker, FILTER_VALIDATE_BOOLEAN); 69 68 70 // shortcode content becomes popup text 71 $content_text = empty($content) ? '' : $content; 72 // alternatively, the popup_text attribute works as popup text 73 $popup_text = empty($popup_text) ? '' : $popup_text; 74 // choose which one takes priority (content_text) 75 $popup_text = empty($content_text) ? $popup_text : $content_text; 76 69 // Enclosed content takes priority. Decode legacy attribute markup before JSON encoding. 70 $popup_text = empty($content) 71 ? html_entity_decode(empty($popup_text) ? '' : $popup_text, ENT_QUOTES | ENT_HTML5, 'UTF-8') 72 : $content; 77 73 $popup_property = empty($popup_property) ? '' : $popup_property; 78 79 $popup_text = trim($popup_text); 74 $popup_json_flags = JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_APOS | JSON_HEX_QUOT; 80 75 81 76 $table_view = filter_var(empty($table_view) ? 0 : $table_view, FILTER_VALIDATE_INT); … … 108 103 if (table_view) { 109 104 text = window.WPLeafletMapPlugin.propsToTable(props); 110 } else { 111 text = popup_property 112 ? props[ popup_property ] 113 : window.WPLeafletMapPlugin.template( 114 popup_text, 115 feature.properties 116 ); 105 } else if (popup_property) { 106 // Check the value before wrapping it in a truthy DOM element. 107 text = props[ popup_property ]; 108 if (text) { 109 text = window.WPLeafletMapPlugin.textPopup(text); 110 } 111 } else if (popup_text) { 112 text = window.WPLeafletMapPlugin.templatePopup( 113 popup_text, 114 props 115 ); 117 116 } 118 117 if (text) { … … 149 148 var fitbounds = <?php echo $fitbounds ? '1' : '0'; ?>; 150 149 var circleMarker = <?php echo $circleMarker ? '1' : '0'; ?>; 151 var popup_text = window.WPLeafletMapPlugin.unescape("<?php echo esc_js( 152 $popup_text 153 ); ?>"); 154 var popup_property = "<?php echo esc_js($popup_property); ?>"; 150 var popup_text = <?php echo $this->LM->encode_popup_html(trim($popup_text)); ?>; 151 var popup_property = <?php echo wp_json_encode($popup_property, $popup_json_flags) ?: '""'; ?>; 155 152 var table_view = <?php echo $table_view; ?>; 156 153 var group = window.WPLeafletMapPlugin.getCurrentGroup(); -
leaflet-map/tags/3.4.8/shortcodes/class.image-overlay-shortcode.php
r2863840 r3832013 19 19 { 20 20 protected $type = 'L.imageOverlay'; 21 protected $default_src = 'https:// maps.lib.utexas.edu/maps/historical/newark_nj_1922.jpg';21 protected $default_src = 'https://leafletjs.com/examples/overlays/newark_nj_1922.jpg'; 22 22 protected $default_bounds = "40.712216,-74.22655;40.773941,-74.12544"; 23 23 -
leaflet-map/tags/3.4.8/shortcodes/class.wms-shortcode.php
r3019392 r3832013 33 33 protected function getHTML($atts = '', $content = null) 34 34 { 35 $atts = (array) $atts; 36 $default_source = 'https://gibs.earthdata.nasa.gov/wms/epsg3857/best/wms.cgi?'; 37 $default_layer = 'BlueMarble_ShadedRelief_Bathymetry'; 38 $source = empty($atts['src']) 39 ? (empty($atts['source']) ? $default_source : $atts['source']) 40 : $atts['src']; 41 $atts['source'] = filter_var($source, FILTER_SANITIZE_URL); 42 $atts['layer'] = empty($atts['layer']) ? $default_layer : $atts['layer']; 43 44 if ( 45 $atts['source'] === $default_source && 46 $atts['layer'] === $default_layer && 47 !array_key_exists('attribution', $atts) 48 ) { 49 $atts['attribution'] = 'NASA GIBS'; 50 } 51 35 52 extract($this->getAtts($atts)); 36 53 … … 52 69 $lng = $this->LM->filter_float($lng); 53 70 54 /* only required field for image map (src/source) */55 $src = empty($src) ? '' : $src;56 $source = empty($source)57 ? 'https://ows.mundialis.de/services/service?'58 : $source;59 $source = filter_var(empty($src) ? $source : $src, FILTER_SANITIZE_URL);60 61 $layer = empty($layer) ? 'TOPO-OSM-WMS' : $layer;62 63 71 $crs = str_replace(':', '', empty($crs) ? 'EPSG:3857' : $crs); 64 65 if ($source == 'https://ows.mundialis.de/services/service?' && $layer == 'TOPO-OSM-WMS') {66 $attribution = empty($attribution) ? '© OpenStreetMap Contributors' : $attribution;67 }68 $attribution = empty($attribution) ? '' : $attribution;69 72 70 73 ob_start(); -
leaflet-map/tags/3.4.8/templates/shortcode-helper.php
r3519096 r3832013 110 110 __("Add GeoJSON with circle markers and popups", 'leaflet-map') => array( 111 111 '[leaflet-map fitbounds scrollwheel]', 112 '[leaflet-geojson circleMarker radius=10 src=https://gist.githubusercontent.com/bozdoz/064a7101b95a324e8852fe9381ab9a18/raw/ee100561f5a0a8cf55430e9f2157e4a1e2560a2e/map.geojson]{popup-text} [/leaflet-geojson]'112 '[leaflet-geojson circleMarker radius=10 src=https://gist.githubusercontent.com/bozdoz/064a7101b95a324e8852fe9381ab9a18/raw/ee100561f5a0a8cf55430e9f2157e4a1e2560a2e/map.geojson]{popup-text}<br><img src="https://picsum.photos/seed/leaflet-map/50/50" alt="GeoJSON popup example" width="50" height="50">[/leaflet-geojson]' 113 113 ), 114 114 __("Add KML by URL", 'leaflet-map') => array( … … 124 124 ), 125 125 __("Image Map", 'leaflet-map') => array( 126 '[leaflet-image zoom=1 zoomcontrol scrollwheel !attribution]',127 '[leaflet-marker draggable] '126 '[leaflet-image src="https://picsum.photos/seed/leaflet-map/1000/1000" zoom=1 zoomcontrol scrollwheel !attribution]', 127 '[leaflet-marker draggable]<img src="https://picsum.photos/seed/leaflet-map/50/50" alt="Image Map example" width="50" height="50">[/leaflet-marker]' 128 128 ), 129 129 __("Image Overlay Map", 'leaflet-map') => array( … … 138 138 '[leaflet-wms zoomControl zoom=5 lat=38.9252 lng=35.33203 attribution="For Those of Us in Turkey"]', 139 139 ), 140 __("Prevents XSS", 'leaflet-map') => array( 141 '[leaflet-map fitbounds scrollwheel]', 142 '[leaflet-geojson circleMarker radius=10 src=https://gist.githubusercontent.com/bozdoz/064a7101b95a324e8852fe9381ab9a18/raw/ee100561f5a0a8cf55430e9f2157e4a1e2560a2e/map.geojson]{popup-text}<br><img src="broken-image.png" onerror="console.log(\'GeoJSON XSS test:\', this.closest(\'.leaflet-popup-content\') ? \'popup\' : \'shortcode preview\')" alt="GeoJSON XSS prevention example" width="50" height="50">[/leaflet-geojson]', 143 '[leaflet-marker lat=44.67 lng=-63.61]<img src="broken-image.png" onerror="console.log(\'Marker XSS test:\', this.closest(\'.leaflet-popup-content\') ? \'popup\' : \'shortcode preview\')" alt="Marker XSS prevention example" width="50" height="50">[/leaflet-marker]' 144 ), 140 145 ); 141 146 … … 145 150 foreach ($collection as $shortcode) { 146 151 echo do_shortcode($shortcode); 147 echo "<p>$shortcode</p>";152 echo '<p>' . esc_html($shortcode) . '</p>'; 148 153 } 149 154 echo '</div>'; -
leaflet-map/trunk/README.md
r3483997 r3832013 191 191 `layer` for the layer name and `crs` for the coordination system (only supported by 192 192 leaflet: EPSG:3857 and EPSG:4326). 193 194 The default source is [NASA GIBS](https://nasa-gibs.github.io/gibs-api-docs/access-basics/), 195 using Blue Marble imagery with shaded relief and bathymetry. 196 193 197 ``` 194 198 [leaflet-wms source="https://your/wms/service?" layer="yourLayer" crs="EPSG:3857" zoom=1] … … 199 203 | Option | Default | 200 204 | ----------------- | ----------------------------------------- | 201 | `src` | https:// ows.mundialis.de/services/service? |202 | `layer ` | TOPO-OSM-WMS|205 | `src` | https://gibs.earthdata.nasa.gov/wms/epsg3857/best/wms.cgi? | 206 | `layer ` | BlueMarble_ShadedRelief_Bathymetry | 203 207 | `crs ` | EPSG:3857 | 204 208 | `zoom` | 12 | … … 211 215 | `min_zoom` | 0 | 212 216 | `max_zoom` | 20 | 213 | `attribution` | ©Leaflet ©OpenStreetMap|217 | `attribution` | NASA GIBS (for the default source and layer) | 214 218 | `lat` | 0 | 215 219 | `lng` | 0 | … … 327 331 `[leaflet-geojson]Field A = {field_a}[/leaflet-geojson]`. 328 332 333 Popup HTML in shortcode content is filtered through WordPress's `wp_kses_post()`. 334 Feature properties, including `popup_property` and table values, are displayed as text. 335 To display an image from a feature property, use a template such as 336 `[leaflet-geojson]<img src="{photo_url}" alt="{title}" width="50" height="50">[/leaflet-geojson]`. 337 Image URL substitutions accept HTTP(S) and relative URLs; event handlers are removed. 338 329 339 ### [leaflet-kml] 330 340 -
leaflet-map/trunk/class.leaflet-map.php
r3519096 r3832013 211 211 if (defined('WP_DEBUG') && WP_DEBUG) { 212 212 $minified = ''; 213 $script_version = LEAFLET_MAP__PLUGIN_VERSION . '.' . filemtime(LEAFLET_MAP__PLUGIN_DIR . 'scripts/construct-leaflet-map.js'); 213 214 } else { 214 215 $minified = '.min'; 216 $script_version = LEAFLET_MAP__PLUGIN_VERSION; 215 217 } 216 218 … … 220 222 221 223 /* run a construct function in the document head for subsequent functions to use (it is lightweight) */ 222 wp_register_script('wp_leaflet_map', plugins_url(sprintf('scripts/construct-leaflet-map%s.js', $minified), __FILE__), Array('leaflet_js'), LEAFLET_MAP__PLUGIN_VERSION, false);224 wp_register_script('wp_leaflet_map', plugins_url(sprintf('scripts/construct-leaflet-map%s.js', $minified), __FILE__), Array('leaflet_js'), $script_version, false); 223 225 } 224 226 … … 358 360 359 361 /** 362 * Sanitize popup HTML and encode it for an inline JavaScript value. 363 * 364 * @param string $content Popup HTML. 365 * @return string JSON-encoded, sanitized HTML. 366 */ 367 public function encode_popup_html($content) 368 { 369 return wp_json_encode( 370 wp_kses_post($content), 371 JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_APOS | JSON_HEX_QUOT 372 ) ?: '""'; 373 } 374 375 /** 360 376 * Add Popups to Shapes 361 377 * … … 393 409 394 410 $message = str_replace(array("\r\n", "\n", "\r"), '<br>', $message); 395 $message = wp_kses_post( $message ); 396 $message = esc_html( $message ); 397 398 $message = "window.WPLeafletMapPlugin.unescape('{$message}')"; 411 $message = $this->encode_popup_html($message); 399 412 400 413 // use with: add_filter('leaflet_map_popup_message', 'example_callback', 10, 3); -
leaflet-map/trunk/leaflet-map.php
r3659792 r3832013 9 9 * Text Domain: leaflet-map 10 10 * Domain Path: /languages/ 11 * Version: 3.4. 711 * Version: 3.4.8 12 12 * License: GPL2 13 13 * Leaflet Map is free software: you can redistribute it and/or modify … … 30 30 } 31 31 32 define('LEAFLET_MAP__PLUGIN_VERSION', '3.4. 7');32 define('LEAFLET_MAP__PLUGIN_VERSION', '3.4.8'); 33 33 define('LEAFLET_MAP__PLUGIN_FILE', __FILE__); 34 34 define('LEAFLET_MAP__PLUGIN_DIR', plugin_dir_path(__FILE__)); -
leaflet-map/trunk/readme.txt
r3659792 r3832013 7 7 Tags: leaflet, map, openstreetmap, mapquest, interactive 8 8 Requires at least: 4.6 9 Tested up to: 7. 110 Version: 3.4. 711 Stable tag: 3.4. 79 Tested up to: 7.2 10 Version: 3.4.8 11 Stable tag: 3.4.8 12 12 License: GPLv2 13 13 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 120 120 121 121 Sure. Use the same attributes as leaflet-map, but use the `[leaflet-wms]` shortcode; attributes include: `src`, `layer`, and `crs`. 122 123 By default, it uses NASA GIBS Blue Marble imagery with shaded relief and bathymetry. 122 124 123 125 = Can I add a message to a marker? = … … 157 159 158 160 == Changelog == 161 162 = 3.4.8 = 163 * [Security] Fix stored cross-site scripting in shortcode popup content. 164 * [Bugfix] Replace the unavailable default WMS source with NASA GIBS Blue Marble imagery. 165 * Tested with WordPress 7.2 159 166 160 167 = 3.4.7 = -
leaflet-map/trunk/scripts/construct-leaflet-map.js
r3043427 r3832013 177 177 }; 178 178 179 function escapeHTML(value) { 180 return String(value).replace(/[&<>"']/g, function (character) { 181 return { 182 '&': '&', 183 '<': '<', 184 '>': '>', 185 '"': '"', 186 "'": ''', 187 }[character]; 188 }); 189 } 190 191 /** Remote property HTML is data, never markup. */ 192 this.textPopup = function (value) { 193 var container = document.createElement('div'); 194 container.textContent = value == null ? '' : String(value); 195 return container; 196 }; 197 198 /** 199 * The template has already passed through wp_kses_post() in PHP. 200 * Parse it inertly, then insert feature values without parsing them as HTML. 201 */ 202 this.templatePopup = function (html, data) { 203 var template = document.createElement('template'); 204 var container = document.createElement('div'); 205 if (!('content' in template)) { 206 container.textContent = interpolate(html, data); 207 return container; 208 } 209 template.innerHTML = html; 210 211 function fill(node) { 212 if (node.nodeType === 3) { 213 node.textContent = interpolate(node.textContent, data); 214 } else if (node.nodeType === 1) { 215 // Only these attributes accept feature substitutions. In particular, 216 // never substitute into CSS, event handlers or attribute names. 217 var attributes = Array.prototype.slice.call(node.attributes); 218 for (var i = 0; i < attributes.length; i++) { 219 var attribute = attributes[i]; 220 var name = attribute.name; 221 if (attribute.value.search(templateRe) === -1) { 222 continue; 223 } 224 if (!/^(alt|title|width|height|href|src)$/.test(name)) { 225 node.removeAttribute(name); 226 continue; 227 } 228 var value = interpolate(attribute.value, data); 229 if (name === 'href' || name === 'src') { 230 // Resolve relative URLs and normalize obfuscated schemes before 231 // checking. Escaping quotes alone cannot stop javascript: URLs. 232 var url = document.createElement('a'); 233 url.href = value; 234 var allowed = 235 name === 'src' ? /^(https?:)$/i : /^(https?:|mailto:|tel:)$/i; 236 if (!allowed.test(url.protocol)) { 237 node.removeAttribute(name); 238 continue; 239 } 240 } 241 node.setAttribute(name, value); 242 } 243 } 244 for (var child = node.firstChild; child; child = child.nextSibling) { 245 fill(child); 246 } 247 } 248 249 fill(template.content); 250 container.appendChild(template.content); 251 return container; 252 }; 253 179 254 /** Adds all properties as a table-view for GeoJSON popups */ 180 255 this.propsToTable = function (props) { … … 192 267 for (var i = 0, len = keys.length; i < len; i++) { 193 268 var key = keys[i]; 194 output += '<tr><td>' + key+ '</td>';195 output += '<td>' + props[key]+ '</td></tr>';269 output += '<tr><td>' + escapeHTML(key) + '</td>'; 270 output += '<td>' + escapeHTML(props[key]) + '</td></tr>'; 196 271 } 197 272 … … 224 299 225 300 var unescape = (this.unescape = function (str) { 226 var div = document.createElement('div'); 227 div.innerHTML = str; 228 return div.innerText || str; 301 // Decode entities in template keys without parsing them as markup. 302 var textarea = document.createElement('textarea'); 303 textarea.innerHTML = str.replace(/</g, '<'); 304 return textarea.value; 229 305 }); 230 306 … … 239 315 * @param {object} data e.g. feature.properties 240 316 */ 241 this.template = function (str, data) {317 function interpolate(str, data, escapeValues) { 242 318 if (data == null) { 243 319 return str; … … 250 326 return obj.default || match; 251 327 } 252 return value;328 return escapeValues ? escapeHTML(value) : String(value); 253 329 }); 330 } 331 332 this.template = function (str, data) { 333 return interpolate(str, data, true); 254 334 }; 255 335 -
leaflet-map/trunk/scripts/construct-leaflet-map.min.js
r3659792 r3832013 1 (function(){function y(){var m="v3.4.7";this.VERSION=m;function v(t){try{t()}catch(n){console.log("-- version --",m),console.error(n)}}var g=!1,f=[];this.push=function(t){g?v(t):f.push(t)},this.unshift=function(t){g?v(t):f.unshift(t)},this.init=function(){g=!0;for(var t=0,n=f.length;t<n;t++)v(f[t])},this.createMap=function(t){var n=document.getElementsByClassName("WPLeafletMap"),e=this.maps.length,i=n[e],r=L.map(i,t);return t.fitBounds&&(r._shouldFitBounds=!0),t.attribution&&T(t.attribution,r),this.maps.push(r),r},this.createImageMap=function(t){var n=this.createMap(t);return n.is_image_map=!0,this.images.push(n),n},this.getCurrentMap=function(){return this.maps[this.maps.length-1]},this.getCurrentGroup=function(){var t=this.maps.length;return this.markergroups[t]||(this.markergroups[t]=this.newMarkerGroup(this.maps[t-1])),this.markergroups[t]},this.getCurrentMarkerGroup=this.getCurrentGroup,this.getGroup=function(t){return new L.FeatureGroup().addTo(t)},this.newMarkerGroup=function(t){var n=this.getGroup(t);return n.timeout=null,t._shouldFitBounds&&n.on("layeradd",function(e){e.layer instanceof L.FeatureGroup&&e.layer.on("ready",function(){t.fitBounds(n.getBounds())}),window.clearTimeout(this.timeout),this.timeout=window.setTimeout(function(){try{t.fitBounds(n.getBounds())}catch{}},100)},n),n},this.propsToTable=function(t){var n,e=[];for(n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.push(n);e=e.sort();for(var i="<table>",r=0,a=e.length;r<a;r++){var o=e[r];i+="<tr><td>"+o+"</td>",i+="<td>"+t[o]+"</td></tr>"}return i+="</table>",i};function P(t){return t.trim()}function T(t,n){if(t)for(var e=t.split(";"),i=L.control.attribution({prefix:!1}).addTo(n),r=0,a=e.length;r<a;r++){var o=P(e[r]);i.addAttribution(o)}}var b=this.unescape=function(t){var n=document.createElement("div");return n.innerHTML=t,n.innerText||t},G=/\{ *(.*?) *\}/g;this.template=function(t,n){return n==null?t:t.replace(G,function(e,i){var r=E(i),a=k(n,r.key);return a??(r.default||e)})};var A=/[.‘’'“”"\[\]]+/g;function S(t){if(t==null)return[];for(var n=t.split(A),e=[],i=0,r=n.length;i<r;i++)n[i]!==""&&e.push(n[i]);return e}function k(t,n){for(var e=S(b(n)),i=t,r=0,a=e.length;r<a;r++)if(i=i[e[r]],!i)return;return i}function E(t){for(var n=t.split(" | "),e={},i=n.shift(),r=0,a=n.length;r<a;r++){var o=n[r].split(": "),h=o.shift(),s=o.join(": ")||!0;e[h]=s}return e.key=i,e}function w(t,n){typeof L<"u"&&typeof L[t]<"u"?n():setTimeout(function(){w(t,n)},100)}this.waitForSVG=function(t){w("SVGIcon",t)},this.waitForAjax=function(t){w("AjaxGeoJSON",t)},this.createScale=function(t){L.control.scale(t).addTo(this.getCurrentMap())},this.getIconOptions=function(t){for(var n=t||{},e=["iconSize","iconAnchor","shadowSize","shadowAnchor","popupAnchor","tooltipAnchor"],i=L.Icon.Default.prototype.options,r=0,a=e.length;r<a;r++){var o=e[r],h=n[o];if(h){for(var s=h.split(","),c=0,B=s.length;c<B;c++)s[c]=Number(s[c]);n[o]=s}}return n.popupAnchor||(n.popupAnchor=function(l){return l=l.slice(),l[0]=0,l[1]*=-1,l[1]-=3,l}(n.iconSize||i.iconSize)),n.iconUrl&&(n.icon=new L.Icon(n)),n},this.maps=[],this.images=[],this.markergroups={},this.markers=[],this.lines=[],this.polygons=[],this.circles=[],this.geojsons=[],this.overlays=[]}var u=window.WPLeafletMapPlugin;if(window.WPLeafletMapPlugin=new y,u){for(var p=0,M=u.length;p<M;p++)window.WPLeafletMapPlugin.push(u[p]);u.splice(0);for(var d in u)u.hasOwnProperty(d)&&(window.WPLeafletMapPlugin[d]=u[d])}window.addEventListener?window.addEventListener("load",window.WPLeafletMapPlugin.init,!1):window.attachEvent&&window.attachEvent("onload",window.WPLeafletMapPlugin.init)})();1 (function(){function S(){var T="v3.4.8";this.VERSION=T;function w(t){try{t()}catch(e){console.log("-- version --",T),console.error(e)}}var y=!1,h=[];this.push=function(t){y?w(t):h.push(t)},this.unshift=function(t){y?w(t):h.unshift(t)},this.init=function(){y=!0;for(var t=0,e=h.length;t<e;t++)w(h[t])},this.createMap=function(t){var e=document.getElementsByClassName("WPLeafletMap"),r=this.maps.length,i=e[r],n=L.map(i,t);return t.fitBounds&&(n._shouldFitBounds=!0),t.attribution&&E(t.attribution,n),this.maps.push(n),n},this.createImageMap=function(t){var e=this.createMap(t);return e.is_image_map=!0,this.images.push(e),e},this.getCurrentMap=function(){return this.maps[this.maps.length-1]},this.getCurrentGroup=function(){var t=this.maps.length;return this.markergroups[t]||(this.markergroups[t]=this.newMarkerGroup(this.maps[t-1])),this.markergroups[t]},this.getCurrentMarkerGroup=this.getCurrentGroup,this.getGroup=function(t){return new L.FeatureGroup().addTo(t)},this.newMarkerGroup=function(t){var e=this.getGroup(t);return e.timeout=null,t._shouldFitBounds&&e.on("layeradd",function(r){r.layer instanceof L.FeatureGroup&&r.layer.on("ready",function(){t.fitBounds(e.getBounds())}),window.clearTimeout(this.timeout),this.timeout=window.setTimeout(function(){try{t.fitBounds(e.getBounds())}catch{}},100)},e),e};function M(t){return String(t).replace(/[&<>"']/g,function(e){return{"&":"&","<":"<",">":">",'"':""","'":"'"}[e]})}this.textPopup=function(t){var e=document.createElement("div");return e.textContent=t==null?"":String(t),e},this.templatePopup=function(t,e){var r=document.createElement("template"),i=document.createElement("div");if(!("content"in r))return i.textContent=p(t,e),i;r.innerHTML=t;function n(o){if(o.nodeType===3)o.textContent=p(o.textContent,e);else if(o.nodeType===1)for(var a=Array.prototype.slice.call(o.attributes),c=0;c<a.length;c++){var s=a[c],u=s.name;if(s.value.search(A)!==-1){if(!/^(alt|title|width|height|href|src)$/.test(u)){o.removeAttribute(u);continue}var v=p(s.value,e);if(u==="href"||u==="src"){var l=document.createElement("a");l.href=v;var I=u==="src"?/^(https?:)$/i:/^(https?:|mailto:|tel:)$/i;if(!I.test(l.protocol)){o.removeAttribute(u);continue}}o.setAttribute(u,v)}}for(var d=o.firstChild;d;d=d.nextSibling)n(d)}return n(r.content),i.appendChild(r.content),i},this.propsToTable=function(t){var e,r=[];for(e in t)Object.prototype.hasOwnProperty.call(t,e)&&r.push(e);r=r.sort();for(var i="<table>",n=0,o=r.length;n<o;n++){var a=r[n];i+="<tr><td>"+M(a)+"</td>",i+="<td>"+M(t[a])+"</td></tr>"}return i+="</table>",i};function C(t){return t.trim()}function E(t,e){if(t)for(var r=t.split(";"),i=L.control.attribution({prefix:!1}).addTo(e),n=0,o=r.length;n<o;n++){var a=C(r[n]);i.addAttribution(a)}}var G=this.unescape=function(t){var e=document.createElement("textarea");return e.innerHTML=t.replace(/</g,"<"),e.value},A=/\{ *(.*?) *\}/g;function p(t,e,r){return e==null?t:t.replace(A,function(i,n){var o=F(n),a=B(e,o.key);return a==null?o.default||i:r?M(a):String(a)})}this.template=function(t,e){return p(t,e,!0)};var x=/[.‘’'“”"\[\]]+/g;function k(t){if(t==null)return[];for(var e=t.split(x),r=[],i=0,n=e.length;i<n;i++)e[i]!==""&&r.push(e[i]);return r}function B(t,e){for(var r=k(G(e)),i=t,n=0,o=r.length;n<o;n++)if(i=i[r[n]],!i)return;return i}function F(t){for(var e=t.split(" | "),r={},i=e.shift(),n=0,o=e.length;n<o;n++){var a=e[n].split(": "),c=a.shift(),s=a.join(": ")||!0;r[c]=s}return r.key=i,r}function P(t,e){typeof L<"u"&&typeof L[t]<"u"?e():setTimeout(function(){P(t,e)},100)}this.waitForSVG=function(t){P("SVGIcon",t)},this.waitForAjax=function(t){P("AjaxGeoJSON",t)},this.createScale=function(t){L.control.scale(t).addTo(this.getCurrentMap())},this.getIconOptions=function(t){for(var e=t||{},r=["iconSize","iconAnchor","shadowSize","shadowAnchor","popupAnchor","tooltipAnchor"],i=L.Icon.Default.prototype.options,n=0,o=r.length;n<o;n++){var a=r[n],c=e[a];if(c){for(var s=c.split(","),u=0,v=s.length;u<v;u++)s[u]=Number(s[u]);e[a]=s}}return e.popupAnchor||(e.popupAnchor=function(l){return l=l.slice(),l[0]=0,l[1]*=-1,l[1]-=3,l}(e.iconSize||i.iconSize)),e.iconUrl&&(e.icon=new L.Icon(e)),e},this.maps=[],this.images=[],this.markergroups={},this.markers=[],this.lines=[],this.polygons=[],this.circles=[],this.geojsons=[],this.overlays=[]}var f=window.WPLeafletMapPlugin;if(window.WPLeafletMapPlugin=new S,f){for(var g=0,b=f.length;g<b;g++)window.WPLeafletMapPlugin.push(f[g]);f.splice(0);for(var m in f)f.hasOwnProperty(m)&&(window.WPLeafletMapPlugin[m]=f[m])}window.addEventListener?window.addEventListener("load",window.WPLeafletMapPlugin.init,!1):window.attachEvent&&window.attachEvent("onload",window.WPLeafletMapPlugin.init)})(); -
leaflet-map/trunk/shortcodes/class.geojson-shortcode.php
r3522877 r3832013 53 53 if ($content) { 54 54 $content = str_replace(array("\r\n", "\n", "\r"), '<br>', $content); 55 $content = htmlspecialchars($content);56 55 } 57 56 … … 68 67 $circleMarker = filter_var($circleMarker, FILTER_VALIDATE_BOOLEAN); 69 68 70 // shortcode content becomes popup text 71 $content_text = empty($content) ? '' : $content; 72 // alternatively, the popup_text attribute works as popup text 73 $popup_text = empty($popup_text) ? '' : $popup_text; 74 // choose which one takes priority (content_text) 75 $popup_text = empty($content_text) ? $popup_text : $content_text; 76 69 // Enclosed content takes priority. Decode legacy attribute markup before JSON encoding. 70 $popup_text = empty($content) 71 ? html_entity_decode(empty($popup_text) ? '' : $popup_text, ENT_QUOTES | ENT_HTML5, 'UTF-8') 72 : $content; 77 73 $popup_property = empty($popup_property) ? '' : $popup_property; 78 79 $popup_text = trim($popup_text); 74 $popup_json_flags = JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_APOS | JSON_HEX_QUOT; 80 75 81 76 $table_view = filter_var(empty($table_view) ? 0 : $table_view, FILTER_VALIDATE_INT); … … 108 103 if (table_view) { 109 104 text = window.WPLeafletMapPlugin.propsToTable(props); 110 } else { 111 text = popup_property 112 ? props[ popup_property ] 113 : window.WPLeafletMapPlugin.template( 114 popup_text, 115 feature.properties 116 ); 105 } else if (popup_property) { 106 // Check the value before wrapping it in a truthy DOM element. 107 text = props[ popup_property ]; 108 if (text) { 109 text = window.WPLeafletMapPlugin.textPopup(text); 110 } 111 } else if (popup_text) { 112 text = window.WPLeafletMapPlugin.templatePopup( 113 popup_text, 114 props 115 ); 117 116 } 118 117 if (text) { … … 149 148 var fitbounds = <?php echo $fitbounds ? '1' : '0'; ?>; 150 149 var circleMarker = <?php echo $circleMarker ? '1' : '0'; ?>; 151 var popup_text = window.WPLeafletMapPlugin.unescape("<?php echo esc_js( 152 $popup_text 153 ); ?>"); 154 var popup_property = "<?php echo esc_js($popup_property); ?>"; 150 var popup_text = <?php echo $this->LM->encode_popup_html(trim($popup_text)); ?>; 151 var popup_property = <?php echo wp_json_encode($popup_property, $popup_json_flags) ?: '""'; ?>; 155 152 var table_view = <?php echo $table_view; ?>; 156 153 var group = window.WPLeafletMapPlugin.getCurrentGroup(); -
leaflet-map/trunk/shortcodes/class.image-overlay-shortcode.php
r2863840 r3832013 19 19 { 20 20 protected $type = 'L.imageOverlay'; 21 protected $default_src = 'https:// maps.lib.utexas.edu/maps/historical/newark_nj_1922.jpg';21 protected $default_src = 'https://leafletjs.com/examples/overlays/newark_nj_1922.jpg'; 22 22 protected $default_bounds = "40.712216,-74.22655;40.773941,-74.12544"; 23 23 -
leaflet-map/trunk/shortcodes/class.wms-shortcode.php
r3019392 r3832013 33 33 protected function getHTML($atts = '', $content = null) 34 34 { 35 $atts = (array) $atts; 36 $default_source = 'https://gibs.earthdata.nasa.gov/wms/epsg3857/best/wms.cgi?'; 37 $default_layer = 'BlueMarble_ShadedRelief_Bathymetry'; 38 $source = empty($atts['src']) 39 ? (empty($atts['source']) ? $default_source : $atts['source']) 40 : $atts['src']; 41 $atts['source'] = filter_var($source, FILTER_SANITIZE_URL); 42 $atts['layer'] = empty($atts['layer']) ? $default_layer : $atts['layer']; 43 44 if ( 45 $atts['source'] === $default_source && 46 $atts['layer'] === $default_layer && 47 !array_key_exists('attribution', $atts) 48 ) { 49 $atts['attribution'] = 'NASA GIBS'; 50 } 51 35 52 extract($this->getAtts($atts)); 36 53 … … 52 69 $lng = $this->LM->filter_float($lng); 53 70 54 /* only required field for image map (src/source) */55 $src = empty($src) ? '' : $src;56 $source = empty($source)57 ? 'https://ows.mundialis.de/services/service?'58 : $source;59 $source = filter_var(empty($src) ? $source : $src, FILTER_SANITIZE_URL);60 61 $layer = empty($layer) ? 'TOPO-OSM-WMS' : $layer;62 63 71 $crs = str_replace(':', '', empty($crs) ? 'EPSG:3857' : $crs); 64 65 if ($source == 'https://ows.mundialis.de/services/service?' && $layer == 'TOPO-OSM-WMS') {66 $attribution = empty($attribution) ? '© OpenStreetMap Contributors' : $attribution;67 }68 $attribution = empty($attribution) ? '' : $attribution;69 72 70 73 ob_start(); -
leaflet-map/trunk/templates/shortcode-helper.php
r3519096 r3832013 110 110 __("Add GeoJSON with circle markers and popups", 'leaflet-map') => array( 111 111 '[leaflet-map fitbounds scrollwheel]', 112 '[leaflet-geojson circleMarker radius=10 src=https://gist.githubusercontent.com/bozdoz/064a7101b95a324e8852fe9381ab9a18/raw/ee100561f5a0a8cf55430e9f2157e4a1e2560a2e/map.geojson]{popup-text} [/leaflet-geojson]'112 '[leaflet-geojson circleMarker radius=10 src=https://gist.githubusercontent.com/bozdoz/064a7101b95a324e8852fe9381ab9a18/raw/ee100561f5a0a8cf55430e9f2157e4a1e2560a2e/map.geojson]{popup-text}<br><img src="https://picsum.photos/seed/leaflet-map/50/50" alt="GeoJSON popup example" width="50" height="50">[/leaflet-geojson]' 113 113 ), 114 114 __("Add KML by URL", 'leaflet-map') => array( … … 124 124 ), 125 125 __("Image Map", 'leaflet-map') => array( 126 '[leaflet-image zoom=1 zoomcontrol scrollwheel !attribution]',127 '[leaflet-marker draggable] '126 '[leaflet-image src="https://picsum.photos/seed/leaflet-map/1000/1000" zoom=1 zoomcontrol scrollwheel !attribution]', 127 '[leaflet-marker draggable]<img src="https://picsum.photos/seed/leaflet-map/50/50" alt="Image Map example" width="50" height="50">[/leaflet-marker]' 128 128 ), 129 129 __("Image Overlay Map", 'leaflet-map') => array( … … 138 138 '[leaflet-wms zoomControl zoom=5 lat=38.9252 lng=35.33203 attribution="For Those of Us in Turkey"]', 139 139 ), 140 __("Prevents XSS", 'leaflet-map') => array( 141 '[leaflet-map fitbounds scrollwheel]', 142 '[leaflet-geojson circleMarker radius=10 src=https://gist.githubusercontent.com/bozdoz/064a7101b95a324e8852fe9381ab9a18/raw/ee100561f5a0a8cf55430e9f2157e4a1e2560a2e/map.geojson]{popup-text}<br><img src="broken-image.png" onerror="console.log(\'GeoJSON XSS test:\', this.closest(\'.leaflet-popup-content\') ? \'popup\' : \'shortcode preview\')" alt="GeoJSON XSS prevention example" width="50" height="50">[/leaflet-geojson]', 143 '[leaflet-marker lat=44.67 lng=-63.61]<img src="broken-image.png" onerror="console.log(\'Marker XSS test:\', this.closest(\'.leaflet-popup-content\') ? \'popup\' : \'shortcode preview\')" alt="Marker XSS prevention example" width="50" height="50">[/leaflet-marker]' 144 ), 140 145 ); 141 146 … … 145 150 foreach ($collection as $shortcode) { 146 151 echo do_shortcode($shortcode); 147 echo "<p>$shortcode</p>";152 echo '<p>' . esc_html($shortcode) . '</p>'; 148 153 } 149 154 echo '</div>';
Note:
See TracChangeset
for help on using the changeset viewer.