Failing test in test_show_atom
|Assignee:||Eric Davis||% Done:|
(Pulling this out of the discussion from #3391)
I'm getting a failing test in the
test_show_atom(IssuesControllerTest) but it's not reproducible by others. Going to try to work on a patch here.
#1 Updated by Eric Davis about 8 years ago
Looks like an environment issue, since both the test and actual code are escaping quotes (
# Test <?xml version="1.0" encoding="UTF-8"?> <feed xmlns="http://www.w3.org/2005/Atom"> <title></title> <link href="http://test.host/issues/2.atom" rel="self"/> <link href="http://test.host/" rel="alternate"/> <id>http://test.host/</id> <updated>2009-11-10T00:00:00-08:00</updated> <author> <name>Redmine</name> </author> <entry> <title>eCookbook - Feature request #2: Add ingredients categories</title> <link href="http://test.host/issues/2" rel="alternate"/> <id>http://test.host/issues/2?journal_id=3</id> <updated>2009-11-10T00:00:00-08:00</updated> <author> <name>John Smith</name> <email>firstname.lastname@example.org</email> </author> <content type="html"> <ul></ul><p>A comment with inline image: <img src="http://test.host/attachments/download/10" alt="" /></p> </content> </entry> </feed>
Atom feed (displays the image properly):
<entry> <title>Digitized 24 hour firmware - Bug #398: Face to face fault-tolerant approach</title> <link href="http://localhost:3000/issues/398" rel="alternate"/> <id>http://localhost:3000/issues/398?journal_id=132</id> <updated>2009-11-11T21:02:26-08:00</updated> <author> <name>Redmine Admin</name> <email>email@example.com</email> </author> <content type="html"> <ul><li><strong>File</strong> <a href="/attachments/5/redmine-error.png">redmine-error.png</a> added</li></ul><p>Test <img src="http://localhost:3000/attachments/download/5" alt="" /></p> </content> </entry>
#2 Updated by Eric Davis about 8 years ago
This might be from Builder. I'm running 2.1.2 which includes this:
Version 2.0.0 introduces automatically escaped attribute values for the first time. Versions prior to 2.0.0 did not insert escape characters into attribute values in the XML markup. This allowed attribute values to explicitly reference entities, which was occasionally used by a small number of developers. Since strings could always be explicitly escaped by hand, this was not a major restriction in functionality.
However, it did suprise most users of builder. Since the body text is normally escaped, everybody expected the attribute values to be escaped as well. Escaped attribute values were the number one support request on the 1.x Builder series.
Starting with Builder version 2.0.0, all attribute values expressed as strings will be processed and the appropriate characters will be escaped (e.g. "&" will be tranlated to "&"). Attribute values that are expressed as Symbol values will not be processed for escaped characters and will be unchanged in output. (Yes, this probably counts as Symbol abuse, but the convention is convenient and flexible).
Running this by hand, the textilized attributes are escaped:
>> xml = Builder::XmlMarkup.new => inspect >> xml.text! textilizable(change, :notes, :only_path => false) => "<inspect/><p>Test <img src="http://localhost:3000/attachments/download/5" alt="" /></p>"
I don't see any specific version of Builder required for Rails, so maybe we are running different versions which is causing the different output. Jean-Philippe, what version of builder do you have?
#4 Updated by Jean-Philippe Lang about 8 years ago
Double quotes are not escaped:
irb(main):001:0> require 'rubygems' => true irb(main):002:0> require 'builder' => true irb(main):003:0> xml = Builder::XmlMarkup.new => <inspect/> irb(main):004:0> xml.text! '<img src="foo.png" />' => "<inspect/><img src=\"foo.png\" />"
gem list --local builder *** LOCAL GEMS *** builder (2.1.2)
#5 Updated by Eric Davis over 7 years ago
- Status changed from 7 to Resolved
- Target version set to 0.9.4
- % Done changed from 0 to 100
- Resolution set to Fixed
I'm still getting this error and have been since I reported this. I've committed r3558 to try and use a different method of checking the atom response. Let me know if it doesn't work on your system.