Skip to content

Commit

Permalink
Fix: Don't escape & character when sanitizing false
Browse files Browse the repository at this point in the history
  • Loading branch information
Roger Campos committed Mar 8, 2013
1 parent b7be6ea commit a571a63
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
4 changes: 2 additions & 2 deletions lib/assets/javascripts/best_in_place.js
Expand Up @@ -42,7 +42,7 @@ BestInPlaceEditor.prototype = {
if (this.sanitize) {
to_display = this.element.text();
} else {
to_display = this.element.html();
to_display = this.element.html().replace('&', '&');
}
}

Expand Down Expand Up @@ -209,7 +209,7 @@ BestInPlaceEditor.prototype = {

// Trim and Strips HTML from text
sanitizeValue : function(s) {
return jQuery.trim(s);
return jQuery.trim(s);
},

/* Generate the data sent in the POST request */
Expand Down
21 changes: 17 additions & 4 deletions spec/integration/js_spec.rb
Expand Up @@ -792,8 +792,6 @@
end

describe "display_with using a lambda" do


it "should render the money" do
@user.save!
visit user_path(@user)
Expand All @@ -803,8 +801,6 @@
end
end



it "should show the new value using the helper after a successful update" do
@user.save!
visit user_path(@user)
Expand Down Expand Up @@ -887,6 +883,23 @@
end
end

it "should show the input with not-scaped ampersands with sanitize => false" do
@user.description = "A text with an & and a <b>Raw html</b>"
@user.save!

retry_on_timeout do
visit double_init_user_path(@user)

id = BestInPlace::Utils.build_best_in_place_id @user, :description
page.execute_script <<-JS
$("##{id}").click();
JS

text = page.find("##{id} textarea").value
text.should == "A text with an & and a <b>Raw html</b>"
end
end

it "should keep the same value after multipe edits" do
@user.save!

Expand Down
2 changes: 1 addition & 1 deletion test_app/db/schema.rb
Expand Up @@ -32,9 +32,9 @@
t.text "favorite_books"
t.datetime "birth_date"
t.float "money"
t.string "favorite_movie"
t.float "money_proc"
t.string "height"
t.string "favorite_movie"
t.string "favorite_locale"
end

Expand Down

0 comments on commit a571a63

Please sign in to comment.