Use block form of gsub to avoid regexp backref interpolation

The content of this commit message is from @kislyuk's comments on the below two issues.

Fix #383
Fix #511

`gsub!(pattern, replacement) interpolates` regexp backreferences
`gsub!(pattern) do block` doesn't

http://stackoverflow.com/questions/2082457/ruby-gsub-problem-when-using-backreference-and-hashes
This commit is contained in:
bootstraponline
2012-09-09 12:13:30 -06:00
parent 0bcd616668
commit 847f08d952
2 changed files with 30 additions and 8 deletions
+6
View File
@@ -184,6 +184,12 @@ context "Markup" do
assert_equal "<p><code>sed -i '' 's/[[:space:]]*$//'</code></p>", page.formatted_data
end
test "regexp gsub! backref (#383)" do
@wiki.write_page("Potato", :markdown, "`rot13='tr '\''A-Za-z'\'' '\''N-ZA-Mn-za-m'\'`", commit_details)
page = @wiki.page("Potato")
assert_equal "<p><code>rot13='tr '\''A-Za-z'\'' '\''N-ZA-Mn-za-m'\'</code></p>", page.formatted_data
end
test "wiki link within code block" do
@wiki.write_page("Potato", :markdown, " sed -i '' 's/[[:space:]]*$//'", commit_details)
page = @wiki.page("Potato")