diff --git a/Gruntfile.coffee b/Gruntfile.coffee
index ba1d5a8c3..3cbf48cb0 100755
--- a/Gruntfile.coffee
+++ b/Gruntfile.coffee
@@ -16,13 +16,14 @@ module.exports = (grunt) ->
parts = []
text = template
while text
- if part = text.match /^[^{}]+(?!{)/
+ if part = text.match /^(?:[^{}\\]|\\.)+(?!{)/
text = text[part[0].length..]
- context = (context + part[0])
+ unescaped = part[0].replace /\\(.)/g, '$1'
+ context = (context + unescaped)
.replace(/(=['"])[^'"<>]*/g, '$1')
.replace(/(<\w+)( [\w-]+((?=[ >])|=''|=""))*/g, '$1')
.replace(/^([^'"<>]+|<\/?\w+>)*/, '')
- parts.push json part[0]
+ parts.push json unescaped
else if part = text.match /^([^}]){([^}`]*)}/
text = text[part[0].length..]
unless context is '' or (part[1] is '$' and /\=['"]$/.test context) or part[1] is '?'
diff --git a/src/General/Config.coffee b/src/General/Config.coffee
index d30f2cf91..2d9040cbc 100755
--- a/src/General/Config.coffee
+++ b/src/General/Config.coffee
@@ -669,7 +669,7 @@ Config =
sauces: """
https://www.google.com/searchbyimage?image_url=%IMG
http://iqdb.org/?url=%IMG
- http://eye.swfchan.com/search/?q=%name;types:swf
+ http://eye.swfchan.com/search/?q=%name;types:swf;sandbox
#//tineye.com/search?url=%IMG
#https://www.yandex.com/images/search?rpt=imageview&img_url=%IMG
#//saucenao.com/search.php?url=%IMG
diff --git a/src/General/Globals.coffee b/src/General/Globals.coffee
index 82bcf0278..43cd70ca4 100755
--- a/src/General/Globals.coffee
+++ b/src/General/Globals.coffee
@@ -19,3 +19,6 @@ E.cat = (templates) ->
html = ''
html += x.innerHTML for x in templates
html
+
+E.url = (content) ->
+ "data:text/html;charset=utf-8,#{encodeURIComponent content.innerHTML}"
diff --git a/src/General/html/Features/Sandbox.html b/src/General/html/Features/Sandbox.html
new file mode 100644
index 000000000..bc8ddbd52
--- /dev/null
+++ b/src/General/html/Features/Sandbox.html
@@ -0,0 +1,16 @@
+
+[sb] ${url}
+
+
+
+
diff --git a/src/General/html/Settings/Sauce.html b/src/General/html/Settings/Sauce.html
index ff1c76644..bf13382a3 100755
--- a/src/General/html/Settings/Sauce.html
+++ b/src/General/html/Settings/Sauce.html
@@ -3,6 +3,7 @@
You can specify a display text by appending ;text:[text] to the URL.
You can specify the applicable boards by appending ;boards:[board1],[board2].
You can specify the applicable file types by appending ;types:[extension1],[extension2].
+You can open links with scripts and popups disabled by appending ;sandbox.
These parameters will be replaced by their corresponding values:
%TURL: Thumbnail URL.
%URL: Full image URL.
diff --git a/src/Images/Sauce.coffee b/src/Images/Sauce.coffee
index df96fda89..76a45cf80 100755
--- a/src/Images/Sauce.coffee
+++ b/src/Images/Sauce.coffee
@@ -16,15 +16,18 @@ Sauce =
name: 'Sauce'
cb: @node
+ sandbox: (url) ->
+ E.url <%= importHTML('Features/Sandbox') %>
+
createSauceLink: (link, post) ->
return null unless link = link.trim()
parts = {}
- for part, i in link.split /;(?=(?:text|boards|types):)/
+ for part, i in link.split /;(?=(?:text|boards|types|sandbox):?)/
if i is 0
parts['url'] = part
else
- m = part.match /^(\w*):(.*)$/
+ m = part.match /^(\w*):?(.*)$/
parts[m[1]] = m[2]
parts['text'] or= parts['url'].match(/(\w+)\.\w+\//)?[1] or '?'
ext = post.file.url.match(/[^.]*$/)[0]
@@ -55,8 +58,11 @@ Sauce =
return null unless !parts['boards'] or post.board.ID in parts['boards'].split ','
return null unless !parts['types'] or ext in parts['types'].split ','
+ url = parts['url']
+ url = Sauce.sandbox url if parts['sandbox']?
+
a = Sauce.link.cloneNode true
- a.href = parts['url']
+ a.href = url
a.textContent = parts['text']
a.removeAttribute 'target' if /^javascript:/i.test parts['url']
a
diff --git a/src/Linkification/Embedding.coffee b/src/Linkification/Embedding.coffee
index 03b70455d..39fdc13fd 100644
--- a/src/Linkification/Embedding.coffee
+++ b/src/Linkification/Embedding.coffee
@@ -185,7 +185,7 @@ Embedding =
el = $.el 'iframe'
el.setAttribute 'sandbox', 'allow-scripts'
content = <%= html('${a.dataset.uid}') %>
- el.src = "data:text/html;charset=utf-8,#{encodeURIComponent content.innerHTML}"
+ el.src = E.url content
el
title:
api: (uid) -> "https://api.github.com/gists/#{uid}"