assaf/zombie — pull request #423 by Filirom1 (2012-10-15 19:31:39+00:00)
Title: Do not browse content-type we are not able to parse

Hi,

The following exemple fails very badly, because zombie try to parse an image :

[romain@myhost zombie]$ cat exemple.js
var Browser = require("./");
var assert = require("assert");

// Load the page from localhost
browser = new Browser()
browser.visit("http://tylkomrok.pl/wp-content/uploads/2011/01/zombimo_happy_face_zombie.jpg", function () {
console.log('loaded')
});

Here is the output

[romain@myhost zombie]$ node exemple.js
Can't create element 'b�p�$҈�<�r��q�uro�tz��w(#����������9����њ"�h��' (Error: Invalid character: Invalid character in tag name: �) Using a div for now. FIXME!
Can't set attribute 'j�d����n�;���֞' to value '': (Error: Invalid character: attribute name: j�d����n�;���֞)
Can't set attribute '��gw' to value '': (Error: Invalid character: attribute name: ��gw)
Can't set attribute 'g@����8����e0zuv���d�g+?����v)�+##qњ"�e���(���(���(���(���(���cζ���%��(���(���(������z"�n)8��le��^c-6�%����2o*�{r�ce��������f' to value '': (Error: Invalid character: attribute name: g@����8����e0zuv���d�g+?����v)�+##qњ"�e���(���(���(���(���(���cζ���%��(���(���(������z"�n)8��le��^c-6�%����2o*�{r�ce��������f)
Can't create element 'o��[�o�m�$g' (Error: Invalid character: Invalid character in tag name: ��[�) Using a div for now. FIXME!

This PR warns the user that the document could not be parsed, but zombie do not crash.