<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>All Things (v8) &#187; Technology</title>
	<atom:link href="http://www.anthonyeden.com/category/technology/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.anthonyeden.com</link>
	<description>Technology Blog</description>
	<lastBuildDate>Sat, 19 Nov 2011 18:06:44 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Experimental Resolution of Gem Dependencies with DNS</title>
		<link>http://www.anthonyeden.com/2011/07/experimental-resolution-of-gem-dependencies-with-dns/</link>
		<comments>http://www.anthonyeden.com/2011/07/experimental-resolution-of-gem-dependencies-with-dns/#comments</comments>
		<pubDate>Sat, 02 Jul 2011 18:37:54 +0000</pubDate>
		<dc:creator>Anthony</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[dns]]></category>
		<category><![CDATA[rubygems]]></category>

		<guid isPermaLink="false">http://www.anthonyeden.com/?p=228</guid>
		<description><![CDATA[This week Jeremy Hinegardner (aka @copiousfreetime) was in Montpellier to visit. In addition to enjoying some good meals, good wine and time in the pool we also took this opportunity to work on an experimental gem dependency resolution system using DNS. I&#8217;ve written about this before and the latest gist has some new details in [...]]]></description>
			<content:encoded><![CDATA[<p>This week Jeremy Hinegardner (aka <a href="http://twitter.com/copiousfreetime">@copiousfreetime</a>) was in Montpellier to visit. In addition to enjoying some good meals, good wine and time in the pool we also took this opportunity to work on an experimental gem dependency resolution system using DNS. I&#8217;ve written about this before and the <a href="https://gist.github.com/1057357">latest gist</a> has some new details in it as the result of our work this week.</p>
<p>First of all we&#8217;ve outlined how to deal with some of the dependency issues we had not yet dealt with, such as less-than, less-than-or-equals-to and not-equals. Additionally we outlined how to deal with situations where a dependency defines 2 or more requirements (such as ["> 1.0.0", "<= 2.0.0"]). We&#8217;ve also added in support for listing all known versions of a specific gem by moving the notion of the latest gem version so it uses a prefix of latest and then putting one PTR for each version of the gem on the gem domain name.</p>
<p>In addition to working on the details of the spec we also got some data loaded! Thanks to the work Jeremy did previously on his <a href="https://github.com/copiousfreetime/gemology">Gemology project</a> a lot of the code had already been written. I spent some time working on moving the code we needed into the <a href="https://github.com/aeden/rubygems-dns">rubygems-dns</a> project while Jeremy worked on exporting the existing specs we needed from his database and writing an import script. While the implementation is far from complete I&#8217;m happy to say that you can actually query the DNS server now and answer questions with it.</p>
<p>First a query to list all of the versions of a gem. We&#8217;ll use the Sinatra gem as an example:</p>
<p><code><br />
dig @ns8.dnsimple.com sinatra.index.rubygems.org PTR<br />
</code></p>
<p>The result will be an unordered list of PTR records, with each record representing a version with the version number in reverse order:</p>
<p><code><br />
sinatra.index.rubygems.org. 86400 IN	PTR	1.3.0.sinatra.index.rubygems.org.<br />
sinatra.index.rubygems.org. 86400 IN	PTR	0.1.0.sinatra.index.rubygems.org.<br />
sinatra.index.rubygems.org. 86400 IN	PTR	5.1.0.sinatra.index.rubygems.org.<br />
sinatra.index.rubygems.org. 86400 IN	PTR	6.1.0.sinatra.index.rubygems.org.<br />
sinatra.index.rubygems.org. 86400 IN	PTR	7.1.0.sinatra.index.rubygems.org.<br />
sinatra.index.rubygems.org. 86400 IN	PTR	0.2.0.sinatra.index.rubygems.org.<br />
...snip...<br />
</code></p>
<p>So the first line indicates that there was a 0.3.1 version of Sinatra and line 2 indicates there was a 0.1.0 version of Sinatra.</p>
<p>Next, let&#8217;s get the latest version:</p>
<p><code><br />
dig @ns8.dnsimple.com latest.sinatra.index.rubygems.org CNAME<br />
</code></p>
<p><code><br />
latest.sinatra.index.rubygems.org. 600 IN CNAME	e.0.3.1.sinatra.index.rubygems.org.<br />
</code></p>
<p>This shows us that 1.3.0.e is the latest sinatra version published (as of the snapshot).</p>
<p>Next, we can query for PTR records for that same name:</p>
<p><code><br />
dig @ns8.dnsimple.com latest.sinatra.index.rubygems.org PTR<br />
</code></p>
<p><code><br />
latest.sinatra.index.rubygems.org. 600 IN CNAME	e.0.3.1.sinatra.index.rubygems.org.<br />
e.0.3.1.sinatra.index.rubygems.org. 86400 IN PTR 1.tilt.index.rubygems.org.<br />
e.0.3.1.sinatra.index.rubygems.org. 86400 IN PTR 1.rack.index.rubygems.org.<br />
</code></p>
<p>This shows us that the version 1.3.0.e has two runtime dependencies, tilt and rack, and that they require the latest version of the 1.x releases for each of those. We can then use:</p>
<p><code><br />
dig @ns8.dnsimple.com 1.tilt.index.rubygems.org PTR<br />
</code></p>
<p>To show us that the latest version:</p>
<p><code><br />
1.tilt.index.rubygems.org. 600	IN	CNAME	2.3.1.tilt.index.rubygems.org<br />
</code></p>
<p>That&#8217;s it for now. There is more work to do, like encoding the <, <=, != and dependencies with 2 or more requirements, but this will at least give an example how this all might actually work.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.anthonyeden.com/2011/07/experimental-resolution-of-gem-dependencies-with-dns/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Service for Subdomains Resolving to URLs</title>
		<link>http://www.anthonyeden.com/2011/04/service-for-subdomains-resolving-to-urls/</link>
		<comments>http://www.anthonyeden.com/2011/04/service-for-subdomains-resolving-to-urls/#comments</comments>
		<pubDate>Sun, 03 Apr 2011 09:47:11 +0000</pubDate>
		<dc:creator>Anthony</dc:creator>
				<category><![CDATA[DNSimple]]></category>
		<category><![CDATA[Flotsam]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[dns]]></category>
		<category><![CDATA[idea]]></category>

		<guid isPermaLink="false">http://www.anthonyeden.com/?p=198</guid>
		<description><![CDATA[Recently, Dave Winer posted an entry on scripting.com about a need that he sees in the domain market that he thinks presents a good opportunity for a new startup. The idea is this: make it easy for customers to assign a domain name to a particular resource. Specifically a customer should be able to buy [...]]]></description>
			<content:encoded><![CDATA[<p>Recently, Dave Winer <a href="http://scripting.com/stories/2011/03/22/callForStartupEasyDomainEd.html">posted an entry on scripting.com</a> about a need that he sees in the domain market that he thinks presents a good opportunity for a new startup.</p>
<p>The idea is this: make it easy for customers to assign a domain name to a particular resource. Specifically a customer should be able to buy a domain and then give out subdomains to others or allow them to purchase a subdomain. There should be an API of course, and the whole thing should be really easy to use.</p>
<p>As soon as the article was posted I started receiving tweets from people asking if this might be something interesting for DNSimple to consider. From a technical standpoint it makes sense that DNSimple could do this, likely as a separate service. I started thinking about how it could be implemented and came up with the idea of using NAPTR records as the mechanism for software to query to determine what URL a domain name points to. The second thing would be to include a URL forwarding entry so that if you hit the domain with a browser then you&#8217;d be redirected to the resource.</p>
<p>Let&#8217;s look at an example:</p>
<ul>
<li>Assume I have the domain anthony.com delegated to the name servers for this service.</li>
<li>If I create an entry for twitter.anthony.com and point it to http://twitter.com/aeden then</li>
<li>If I <code>`dig twitter.anthonyeden.com naptr`</code> then I would see</li>
<li><code>twitter.anthony.com.     3600     IN     NAPTR     0 1 "u" "n2u:uri" "!^.*$!http://twitter.com/aeden!" .</code></li>
<li>If I browse to twitter.anthony.com then I would be URL forwarded to http://twitter.com/aeden with a 301 Redirect.</li>
</ul>
<p>The concept is pretty straightforward. I&#8217;ve already created a simple prototype, but before I go any further I wanted to find out if there are other people interested in a service like this. Would you be willing to share revenue on sales of subdomains? Would you be willing and interested in integrating NAPTR DNS lookups in your software as a way to resolve a domain name to a URL?</p>
<p>Edit: There seems to be some question as to whether or not NAPTR records are really needed. Here&#8217;s why I think they are: A 301 redirect will work, however this means that a redirector server has to be hosted by the service that is providing the delegation, in addition to name servers. NAPTR, with adoption by clients (like browsers) means that the DNS record alone could provide all the details that client needs to make its next move. I think that this is a much more scalable long-term solution and thus I would propose that both a URL forwarding system and NAPTR records are useful for a redirect service.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.anthonyeden.com/2011/04/service-for-subdomains-resolving-to-urls/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Why No Wifi at a Tech Conference is a Bad Idea</title>
		<link>http://www.anthonyeden.com/2011/03/why-no-wifi-at-a-tech-conference-is-a-bad-idea/</link>
		<comments>http://www.anthonyeden.com/2011/03/why-no-wifi-at-a-tech-conference-is-a-bad-idea/#comments</comments>
		<pubDate>Tue, 29 Mar 2011 07:50:37 +0000</pubDate>
		<dc:creator>Anthony</dc:creator>
				<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://www.anthonyeden.com/?p=194</guid>
		<description><![CDATA[It seems that SudWeb, a conference near where I live in South France, has made the decision to have no WIFI. Personally I think this is a bad idea and I said so on Twitter, but naturally in 140 characters or less it&#8217;s quite difficult to give a lucid argument, so I&#8217;m going to try [...]]]></description>
			<content:encoded><![CDATA[<p>It seems that <a href="http://sudweb.fr/">SudWeb</a>, a conference near where I live in South France, has made the decision to have no WIFI. Personally I think this is a bad idea and <a href="http://twitter.com/#!/aeden/status/52454778067894272">I said so on Twitter</a>, but naturally in 140 characters or less it&#8217;s quite difficult to give a lucid argument, so I&#8217;m going to try to do that here.</p>
<p>The publicized motive for not having wifi is as follows:</p>
<p>&#8220;nowificonferences comes from the desire to give priority to people and interactions. We want people to come listen and share with each other. By removing the WiFi, we remove useless distractions so that the conference really happens between visitors, speakers and staff.&#8221;</p>
<p>It&#8217;s a reasonable desire but they&#8217;ve taken the wrong approach to achieve their goal. Here&#8217;s why:</p>
<p>1.) Not having WIFI only punishes those of us who do not have a 3G device, of which there are some, but likely not the majority, especially at a technical conference. Developers with 3G devices will still be online during talks, they will still find a corner to go have a conversation with someone online and likely some of them will even turn their devices into hotspots so others can use their connection.</p>
<p>2.) Not having WIFI means that having hands-on exchanges around specific technical projects or specific web sites becomes much more cumbersome for many and impossible for others. For a conference that is billed as being about the web it&#8217;s absurd to not have open and ready access to the web. When I go to a technical conference I often have at least one exchange that involves pulling out a laptop and showing off a site that&#8217;s being worked on or code that is interesting. Again, my guess is this will *still* happen, but over 3G.</p>
<p>3.) There are other means that encourage people to talk and share ideas that are more effective. For example, BizConf 2010 used Improv as a means to get the entire conference engaged in an activity that both broke the ice and encouraged attendees to learn the names of those around them. Many technical conferences are now running hacking spaces at the conference so people can get together and program, exchange techniques and ideas and share. Finally more than a few conferences are running parallel unconferences where people can create adhoc groups around topics of their choosing. All of these ideas approach the issue in a creative way rather than a way that penalizes attendees.</p>
<p>Aside from these reasons there are other practical reasons Wifi matters, from the ability to get emergency work done if necessary to the ability to dig deeper into an idea presented by a presenter to the simple act of following an interesting speaker on Twitter during their talk. These things will still happen, but no one will be thanking the organizers of Sudweb for making it happen.</p>
<p>Most likely the outcome of this decision by Sudweb will be that people who are disappointed by the lack of WIFI just won&#8217;t come to the conference at all. This is the real tragedy because the goal is to get people to show up and communicate face-to-face yet there&#8217;s a good chance that conversations that would have been will now never be.</p>
<p>Update 1: I just realized another aspect of Sudweb&#8217;s choice that bothers me. By dictating that there will be no WIFI because they want it to be about people connecting they are essentially treating their audience like children who need to be told how to behave. Rather than assuming that I, as a mature adult and conference attendee, can choose when, how and with whom I interact at a conference, they attempt to dictate this by setting certain conditions.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.anthonyeden.com/2011/03/why-no-wifi-at-a-tech-conference-is-a-bad-idea/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Presentations in Stockholm</title>
		<link>http://www.anthonyeden.com/2011/03/presentations-in-stockholm/</link>
		<comments>http://www.anthonyeden.com/2011/03/presentations-in-stockholm/#comments</comments>
		<pubDate>Mon, 28 Mar 2011 14:27:30 +0000</pubDate>
		<dc:creator>Anthony</dc:creator>
				<category><![CDATA[Cucumber]]></category>
		<category><![CDATA[Presentations]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://www.anthonyeden.com/?p=191</guid>
		<description><![CDATA[This month I had the pleasure of traveling up to Stockholm to speak at a couple of events there. First let me just say that Stockholm is an amazing city full of style, character and charm. From classic coffee houses to modern restaurants there is something for anyone. I highly recommend visiting if you have [...]]]></description>
			<content:encoded><![CDATA[<p>This month I had the pleasure of traveling up to Stockholm to speak at a couple of events there. First let me just say that Stockholm is an amazing city full of style, character and charm. From classic coffee houses to modern restaurants there is something for anyone. I highly recommend visiting if you have a chance &#8211; you won&#8217;t regret it.</p>
<p>While I was there I gave a talk called &#8220;Why Ruby, Why Now?&#8221; at the first dyncon as well as a talk titled Harnessing Cucumber at Valtech Labs. The first talk was an introduction to Ruby. I have been itching to give an introductory talk for a while and I&#8217;m glad this gave me the chance. The audience was a bit more knowledgeable about Ruby than I expected, so some of the items weren&#8217;t new to them, however I believe there was still enough in the talk to keep people interested. I also blazed through it since it was right before lunch so maybe people were enthralled merely by my lightning-fast presentation skills. <img src='http://www.anthonyeden.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':-D' class='wp-smiley' />  The presentation is available online on Github: <a href="https://github.com/aeden/presentation_why_ruby">https://github.com/aeden/presentation_why_ruby</a> and was created using Scott Chacon&#8217;s <a href="https://github.com/schacon/showoff">Show Off</a>.</p>
<p>The second talk I gave was an intermediate to advanced talk on Cucumber where I covered a lot of what I have learned about Cucumber over the last year of using it. Cucumber has become an important part of my test suites because it allows me to test the experience of using my software. This talk covered some of the various command-line switches and cucumber.yml configuration options in the first section and then moves onto testing APIs and CLIs. I&#8217;ve found that testing both of these interfaces to my applications has helped tremendously in improving the application and at the same time providing a safety net for refactoring, which is exactly what I want from Cucumber. This talk is available <a href="http://dl.dropbox.com/u/3308516/harnessing_cucumber.pdf">as a PDF</a> and was created using Keynote.</p>
<p>I appreciate the support from both of the audiences and the discussions that followed both talks and I look forward to the opportunity to visit Stockholm again in the not-to-distant future. Thanks as well to Peter Svensson for putting together dyncon and to Peter Lind for opening up the Valtech offices for my talk there.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.anthonyeden.com/2011/03/presentations-in-stockholm/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>SuperFeedr and PubSubHubBub</title>
		<link>http://www.anthonyeden.com/2010/08/superfeedr-and-pubsubhubbub/</link>
		<comments>http://www.anthonyeden.com/2010/08/superfeedr-and-pubsubhubbub/#comments</comments>
		<pubDate>Wed, 11 Aug 2010 15:15:36 +0000</pubDate>
		<dc:creator>Anthony</dc:creator>
				<category><![CDATA[chi.mp]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[atom]]></category>
		<category><![CDATA[dotmp]]></category>
		<category><![CDATA[feeds]]></category>
		<category><![CDATA[pubsubhubbub]]></category>
		<category><![CDATA[superfeedr]]></category>

		<guid isPermaLink="false">http://www.anthonyeden.com/?p=160</guid>
		<description><![CDATA[One of the challenges I deal with on a daily basis is trying to keep the feed data flowing into chi.mp home pages. It is very challenging to consume tens-of-thousands of feeds in a reliable fashion. For a long time we did this internally out of necessity. Now though we no longer need to manage [...]]]></description>
			<content:encoded><![CDATA[<p>One of the challenges I deal with on a daily basis is trying to keep the feed data flowing into chi.mp home pages. It is very challenging to consume tens-of-thousands of feeds in a reliable fashion. For a long time we did this internally out of necessity. Now though we no longer need to manage this internally thanks to <a href="http://superfeedr.com/">Superfeedr</a>.</p>
<p>I started considering the idea of using Superfeedr well over six months ago, but still had concerns about their stability and viability &#8211; ultimately I got over that and realized that I <b>need</b> to outsource this part of chi.mp. This week I finally pushed out code for chi.mp that uses SuperFeedr&#8217;s <a href="http://en.wikipedia.org/wiki/PubSubHubbub">PubSubHubBub</a> hub to receive feed updates. Initially I used their XMPP interface, however after repeated encouragement from Julien @ Superfeedr I made the switch over to PubSubHubBub with only a small amount of work.</p>
<p>I still have to move a bunch of feeds over to use Superfeedr but I feel at least part of the burden of managing all of these various feeds beginning to leave my shoulders, and for that I am very thankful.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.anthonyeden.com/2010/08/superfeedr-and-pubsubhubbub/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ship It! DNSimple.com Is Launched</title>
		<link>http://www.anthonyeden.com/2010/07/ship-it-dnsimple-com-is-launched/</link>
		<comments>http://www.anthonyeden.com/2010/07/ship-it-dnsimple-com-is-launched/#comments</comments>
		<pubDate>Tue, 06 Jul 2010 03:01:32 +0000</pubDate>
		<dc:creator>Anthony</dc:creator>
				<category><![CDATA[DNSimple]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[dns]]></category>
		<category><![CDATA[domain]]></category>
		<category><![CDATA[domains]]></category>
		<category><![CDATA[hosted dns]]></category>

		<guid isPermaLink="false">http://www.anthonyeden.com/?p=155</guid>
		<description><![CDATA[The last couple of weeks I&#8217;ve been working hard on putting the finishing touches on DNSimple, a new hosted domain name management service for small businesses and entrepreneurs. After working on domain services for more than 10 years, both as a domain registrar back in the late &#8217;90s and through operating a domain registry and [...]]]></description>
			<content:encoded><![CDATA[<p>The last couple of weeks I&#8217;ve been working hard on putting the finishing touches on <a href="http://dnsimple.com">DNSimple</a>, a new hosted domain name management service for small businesses and entrepreneurs. After working on domain services for more than 10 years, both as a domain registrar back in the late &#8217;90s and through operating a domain registry and registrar for several years, it&#8217;s time for me to put together a DNS service that caters to the needs of other entrepreneurs like me.</p>
<p>What are the specifics? For $10/month you can to manage up to 50 domains using <a href="http://dnsimple.com/">DNSimple</a>. Each domain can have as many records as you need. Our DNS servers are updated almost instantly as you add records to your domain.  We support TTL times as low as 1 minute. Repetitive changes can be set up as templates and we already include a default template for setting up Google MX records for domains that host their mail at Google.</p>
<p>I look forward to getting feedback on what you think of the service, what could be improved and what if anything would keep you from adopting it. You can either <a href="mailto:anthonyeden@gmail.com">contact me via email</a> or <a href="http://twitter.com/aeden">send me a message on Twitter</a>. Thanks!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.anthonyeden.com/2010/07/ship-it-dnsimple-com-is-launched/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Posting to WordPress from my iPad</title>
		<link>http://www.anthonyeden.com/2010/04/posting-to-wordpress-from-my-ipad/</link>
		<comments>http://www.anthonyeden.com/2010/04/posting-to-wordpress-from-my-ipad/#comments</comments>
		<pubDate>Tue, 06 Apr 2010 02:04:17 +0000</pubDate>
		<dc:creator>Anthony</dc:creator>
				<category><![CDATA[Flotsam]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[iPad]]></category>

		<guid isPermaLink="false">http://www.anthonyeden.com/2010/04/posting-to-wordpress-from-my-ipad/</guid>
		<description><![CDATA[I don&#8217;t blog much, that&#8217;s no secret, however with the iPad and specifically the WordPress app on the iPad I might change that. Time will tell how well this works out.]]></description>
			<content:encoded><![CDATA[<p>I don&#8217;t blog much, that&#8217;s no secret, however with the iPad and specifically the WordPress app on the iPad I might change that. Time will tell how well this works out.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.anthonyeden.com/2010/04/posting-to-wordpress-from-my-ipad/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>XSS and Building HTML in JavaScript</title>
		<link>http://www.anthonyeden.com/2010/02/xss-and-building-html-in-javascript/</link>
		<comments>http://www.anthonyeden.com/2010/02/xss-and-building-html-in-javascript/#comments</comments>
		<pubDate>Tue, 16 Feb 2010 22:04:31 +0000</pubDate>
		<dc:creator>Anthony</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[ujs]]></category>

		<guid isPermaLink="false">http://www.anthonyeden.com/?p=123</guid>
		<description><![CDATA[In my recent article on Rails, JQuery, Unobtrusive JS and Graceful Degradation I implemented the Ajax logic for adding a new entry using JSON returned from the server to build the HTML in JavaScript. An attentive reader brought to my attention the cross-site scripting vulnerability that is possible with this implementation and I think this [...]]]></description>
			<content:encoded><![CDATA[<p>In my recent article on <a href="http://www.anthonyeden.com/2010/02/rails-jquery-unobtrusive-js-and-graceful-degradation/">Rails, JQuery, Unobtrusive JS and Graceful Degradation</a> I implemented the Ajax logic for adding a new entry using JSON returned from the server to build the HTML in JavaScript. An attentive reader brought to my attention the cross-site scripting vulnerability that is possible with this implementation and I think this would be a good time to address the issue and open the comments to other options.</p>
<p>First of all let&#8217;s look at the most obvious attack vector, which is pretty simple: a malicious user would enter a script into the person name field and save that and then it would execute the script when the person is rendered in the person list. First I verified that this attack vector worked, and yes it did work, so then I considered where the value entered by the user needed to be sanitized. It&#8217;s pretty straightforward to sanitize the rendering when Rails is involved, just add the <code>h()</code> helper before the name output in the listing, so line 4 of index.html.erb becomes:</p>
<p><script src="http://gist.github.com/305978.js?file=gistfile1.rhtml"></script></p>
<p>This is a fairly standard idiom in Rails (not necessarily the best way to sanitize user input, but the most common way to do it). This fix only fixes the problem when the page is rendered by Rails, but it does not address the issue for items that are added via Ajax, and here is where things get a bit tricky.</p>
<p>You&#8217;d think that sanitizing user input in JavaScript would be fairly easy, and to be clear you can do it with the JavaScript <code>escape()</code> function, however this results in some pretty ugly percent-encoded content (which may or may not matter to you. I was curious though whether there was something similar to the <code>h()</code> helper in Rails available in JavaScript. There is but finding it proved to be a bit of a challenge.</p>
<p>What I ended up doing what searching <a href="http://stackoverflow.com/">Stack Overflow</a> for solutions that others had come up with and eventually landed upon this bit of code: <a href="http://code.google.com/p/google-caja/source/browse/trunk/src/com/google/caja/plugin/html-sanitizer.js">http://code.google.com/p/google-caja/source/browse/trunk/src/com/google/caja/plugin/html-sanitizer.js</a>. Unfortunately this bit of code by itself doesn&#8217;t work unless you have another JS library (html4) and that library requires building with Ant. Fortunately additional searching led me to a minified version with everything already compiled. I&#8217;ve included this minified library as html-sanitizer-minified.js and added a call to html_santize before rendering the person name in the JavaScript as such:</p>
<p><script src="http://gist.github.com/305989.js?file=gistfile1.js"></script></p>
<p>..and it works. I&#8217;ve deployed this fix to <a href="http://rails-jquery-unobtrusive.heroku.com/">http://rails-jquery-unobtrusive.heroku.com/</a> and have updated the <a href="http://github.com/aeden/unobtrusive-jquery-example">github repo</a> so you can see the changes in action.</p>
<p>So is this the best solution for handling user input and avoiding XSS when you want to build HTML in JavaScript? I&#8217;m not sure. It&#8217;s probably not the only solution so feel free to add yours in the comments below. Also, consider this a warning if you are developing JavaScript code that builds and renders HTML: tainted user input is a threat and you need to deal with it.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.anthonyeden.com/2010/02/xss-and-building-html-in-javascript/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Aloha on Rails Talk Online</title>
		<link>http://www.anthonyeden.com/2010/02/aloha-on-rails-talk-online/</link>
		<comments>http://www.anthonyeden.com/2010/02/aloha-on-rails-talk-online/#comments</comments>
		<pubDate>Wed, 10 Feb 2010 17:52:37 +0000</pubDate>
		<dc:creator>Anthony</dc:creator>
				<category><![CDATA[Presentations]]></category>
		<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://www.anthonyeden.com/?p=121</guid>
		<description><![CDATA[Well look at that, the video for my talk from Aloha on Rails is online now. Go check it out if you&#8217;re interested in identifying and reducing your technical debt.]]></description>
			<content:encoded><![CDATA[<p>Well look at that, the video for <a href="http://www.alohaonrails.com/2010/02/09/technical-debt-video-by-anthony-eden-now-online/">my talk from Aloha on Rails is online now</a>. Go check it out if you&#8217;re interested in identifying and reducing your technical debt.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.anthonyeden.com/2010/02/aloha-on-rails-talk-online/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Rails, JQuery, Unobtrusive JS and Graceful Degradation</title>
		<link>http://www.anthonyeden.com/2010/02/rails-jquery-unobtrusive-js-and-graceful-degradation/</link>
		<comments>http://www.anthonyeden.com/2010/02/rails-jquery-unobtrusive-js-and-graceful-degradation/#comments</comments>
		<pubDate>Fri, 05 Feb 2010 21:50:24 +0000</pubDate>
		<dc:creator>Anthony</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[ujs]]></category>

		<guid isPermaLink="false">http://www.anthonyeden.com/?p=115</guid>
		<description><![CDATA[I&#8217;m always on the lookout for ways to improve my web applications. To that end I wanted to see if I could come up with a way to marry jQuery and Rails in a way that was both unobtrusive and a way that would degrade gracefully in a Rails 2.3.5 application. I&#8217;m looking forward to [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m always on the lookout for ways to improve my web applications. To that end I wanted to see if I could come up with a way to marry jQuery and Rails in a way that was both unobtrusive and a way that would degrade gracefully in a Rails 2.3.5 application. I&#8217;m looking forward to seeing how UJS with jQuery in Rails looks as of Rails 3.0, however in the meantime the method I describe below may prove to be useful.</p>
<p>If you want to go straight to the code it is available on Github: <a href="http://github.com/aeden/unobtrusive-jquery-example">http://github.com/aeden/unobtrusive-jquery-example</a>. I have also put a live demo on this up on Heroku: <a href="http://rails-jquery-unobtrusive.heroku.com">http://rails-jquery-unobtrusive.heroku.com</a>.</p>
<p>Rather than going through all of the steps needed to set up a Rails app, the best thing to do is to follow along in the code from the example above.</p>
<p>First let&#8217;s take a look at the PeopleController (app/controllers/people_controller.rb):</p>
<p><script src="http://gist.github.com/296266.js?file=gistfile1.rb"></script></p>
<p>This looks like a fairly normal RESTful controller. The one exception is the delete method, which will be used by browsers that have JavaScript turned off to provide a page that 1.) confirms that the record should be deleted and 2.) has a form that can post to the destroy method.</p>
<p>Next, let&#8217;s take a look at the index view:</p>
<p><script src="http://gist.github.com/296269.js?file=gistfile1.rhtml"></script></p>
<p>There is a list of people with each person having a delete link next to their name. The delete link points to /person/:id/delete which will execute the delete action that I mentioned above (I&#8217;ll show you how to remove the &#8220;/delete&#8221; part of that link with JavaScript later). There is also a form for adding a new person. Note that there is no JavaScript in this page, just normal HTML elements with classes.</p>
<p>While we&#8217;re looking at views, let&#8217;s look at the only other view, the delete view:</p>
<p><script src="http://gist.github.com/296270.js?file=gistfile1.rhtml"></script></p>
<p>This is just a simple form that confirms that they want to delete the user and provides a cancel link back to the people_url if they don&#8217;t. Note that the form tag uses the REST-ful URL for accessing the resource and sets &#8216;_method&#8217; to &#8216;delete&#8217; in the hidden field tag.</p>
<p>Finally, let&#8217;s take a look at the most complicated bit, the jQuery JavaScript. To make things easier to follow I&#8217;ll go through it piece by piece, starting with the document ready handler:</p>
<p><script src="http://gist.github.com/296271.js?file=gistfile1.js"></script></p>
<p>This is the jQuery way for executing code when the document has finished loading. All it does is call two methods, one for connecting up the add form and one for connecting up the delete links. To keep things organized and namespaced a bit I placed these two methods onto a JS object called &#8216;Actions&#8217;. First, the connectAddForm implementation:</p>
<p><script src="http://gist.github.com/296272.js?file=gistfile1.js"></script></p>
<p>This function finds the form element with the class &#8220;people&#8221; and attaches an event handler to the submit event. When the form is submitted an AJAX POST is made. The data type is JSON, which will call the &#8216;create&#8217; action in the people controller with the accepts type set to a value that triggers Rails to render JSON as the response. The form is serialized and passed as data and when a successful response is received a bit of HTML is appended to the people list and the person name field is cleared.</p>
<p>Now for the connect delete links JavaScript:</p>
<p><script src="http://gist.github.com/296273.js?file=gistfile1.js"></script></p>
<p>Here each element that is in the people list that matches the selector a.delete and adds a click handler to it. Notice that I used the jQuery live method here, the benefit being that as new records are added, and new elements that match the selector expression are added automatically get the click handler that I define here. This saves me from the trouble of having to add the handler each time that a record is added to the page. The click handler first finds the li that it may eventually delete, displays a confirmation message to the viewer and if they confirm that they want to delete the record it will post via AJAX to the /person/:id URL with the method &#8216;delete&#8217;. The URL is pulled from the anchor&#8217;s href attribute and the &#8216;/delete&#8217; is removed using a simple regular expression replace. Upon a successful delete the li that was found earlier is hidden using the slideToggle() function.</p>
<p>That&#8217;s it. You can try this in a browser either with JavaScript turned on, in which case it&#8217;ll use all of the JavaScript goodness, or you can turn of JavaScript and see the magic of graceful degradation. I hope you&#8217;ve enjoyed reading this little tutorial and if you have any suggestions on how to improve the code in the project please feel free to fork the github project, make your changes and send me a pull request. I&#8217;ll add any cool mods into the tutorial as I can.</p>
<p><b>Update:</b> I&#8217;ve <a href="http://www.anthonyeden.com/2010/02/xss-and-building-html-in-javascript/">published a follow-on article</a> that talks about changes to the code for this tutorial to handle sanitizing user input both in Rails and in JavaScript. I suggest reading it to understand XSS vulnerabilities that you need to deal with when accepting user input.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.anthonyeden.com/2010/02/rails-jquery-unobtrusive-js-and-graceful-degradation/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

