MediaWiki:Common.js: различия между версиями
добавим блок отработки ошибок+безопасности больше |
добавим также валидацию размеров для ВК и защиту iframe |
||
| Строка 81: | Строка 81: | ||
var height = container.getAttribute('data-height') || '315'; | var height = container.getAttribute('data-height') || '315'; | ||
if (oid && id && oid !== 'null' && id !== 'null' && | width = parseInt(width) || 560; | ||
height = parseInt(height) || 315; | |||
if (width > 2000) width = 2000; | |||
if (height < 100) height = 100; | |||
if (height > 2000) height = 2000; | |||
if (oid && id && oid !== 'null' && id !== 'null' && /^[-_a-zA-Z0-9]+$/.test(oid) && /^[-_a-zA-Z0-9]+$/.test(id)) { | |||
var iframe = document.createElement('iframe'); | var iframe = document.createElement('iframe'); | ||
iframe.src = 'https://vk.com/video_ext.php?oid=' + encodeURIComponent(oid) + '&id=' + encodeURIComponent(id); | iframe.src = 'https://vk.com/video_ext.php?oid=' + encodeURIComponent(oid) + '&id=' + encodeURIComponent(id); | ||
| Строка 90: | Строка 94: | ||
iframe.frameBorder = '0'; | iframe.frameBorder = '0'; | ||
iframe.allowFullscreen = true; | iframe.allowFullscreen = true; | ||
iframe.sandbox = 'allow-scripts allow-same-origin allow-presentation allow-fullscreen'; | |||
iframe.allow = 'fullscreen'; | |||
iframe.style.border = 'none'; | iframe.style.border = 'none'; | ||
| Строка 96: | Строка 104: | ||
} | } | ||
container.appendChild(iframe); | container.appendChild(iframe); | ||
} else { | } else { | ||
} | } | ||
} | } | ||