fixed sanitization for notes, added descaling when saving notes on scaled images
This commit is contained in:
@@ -278,12 +278,16 @@ Danbooru.Note = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
parameterize_note: function($note_box, $note_body) {
|
parameterize_note: function($note_box, $note_body) {
|
||||||
|
var $image = $("#image");
|
||||||
|
var original_width = parseInt($image.data("original-width"));
|
||||||
|
var ratio = parseInt($image.width()) / original_width;
|
||||||
|
|
||||||
var hash = {
|
var hash = {
|
||||||
note: {
|
note: {
|
||||||
x: $note_box.position().left,
|
x: $note_box.position().left / ratio,
|
||||||
y: $note_box.position().top,
|
y: $note_box.position().top / ratio,
|
||||||
width: $note_box.width(),
|
width: $note_box.width() / ratio,
|
||||||
height: $note_box.height(),
|
height: $note_box.height() / ratio,
|
||||||
body: $note_body.html(),
|
body: $note_body.html(),
|
||||||
post_id: Danbooru.meta("post-id")
|
post_id: Danbooru.meta("post-id")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -193,8 +193,12 @@ class DText
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
sanitize(html.join("")).html_safe
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.sanitize(text)
|
||||||
Sanitize.clean(
|
Sanitize.clean(
|
||||||
html.join(""),
|
text,
|
||||||
:elements => %w(h1 h2 h3 h4 h5 h6 a span div blockquote br p ul li ol em strong),
|
:elements => %w(h1 h2 h3 h4 h5 h6 a span div blockquote br p ul li ol em strong),
|
||||||
:attributes => {
|
:attributes => {
|
||||||
"a" => %w(href title),
|
"a" => %w(href title),
|
||||||
@@ -206,7 +210,7 @@ class DText
|
|||||||
"href" => ["http", "https", :relative]
|
"href" => ["http", "https", :relative]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
).html_safe
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
<%= content_tag(:article, raw(Sanitize.clean(note.body)), "data-width" => note.width, "data-height" => note.height, "data-x" => note.x, "data-y" => note.y, "data-id" => note.id) %>
|
<%= content_tag(:article, raw(DText.sanitize(note.body)), "data-width" => note.width, "data-height" => note.height, "data-x" => note.x, "data-y" => note.y, "data-id" => note.id) %>
|
||||||
|
|||||||
Reference in New Issue
Block a user