silverstripe/silverstripe-framework — pull request #3374 by tractorcow (2014-08-10 23:49:53+00:00)
Title: BUG Fix incorrect parsing of HTML content

In jquery 1.8 there is a `jQuery.parseHTML` method. See http://api.jquery.com/jQuery.parseHTML/ for details. Unfortunately, in 1.7 there is no such method, so I've taken an extremely simplified version of the necessary part of that method and backported it for use in 1.7.

The old code uses `$(content)` to encapsulate raw HTML inside a jquery container, but this behaviour is not reliable.

The issue as it stands is that if the content does not include the `<` character at the start of the string then the value can be misinterpreted as a jQuery selector and throws up the error seen at https://travis-ci.org/tractorcow/silverstripe-cms/builds/32177340.

```
Error: Syntax error, unrecognized expression:	} in http://localhost:8000/framework/thirdparty/jquery/jquery.js?m=1407542257:4267:1
STACKTRACE:
Sizzle.error@http://localhost:8000/framework/thirdparty/jquery/jquery.js?m=1407542257:4267:2
Sizzle.filter@http://localhost:8000/framework/thirdparty/jquery/jquery.js?m=1407542257:4253:5
Sizzle@http://localhost:8000/framework/thirdparty/jquery/jquery.js?m=1407542257:4043:1
Sizzle@http://localhost:8000/framework/thirdparty/jquery/jquery.js?m=1407542257:5175:4
.find@http://localhost:8000/framework/thirdparty/jquery/jquery.js?m=1407542257:5431:4
jQuery