Although it’s not more than three weeks since BlogEngine.NET 1.4 was released, we have no choice but to release a new version. There was a security issue which was fixed at made available for download and some huge edge case bugs as well. Also, the memory leak fix needed to be part of an official new release.

Fixes

Below are listed some major fixes and a description of what the problem was and who it effects.

The profile provider

If you we running in medium trust, the profile provider threw a security exception because medium trust doesn’t allow reflection. The ASP.NET build-in profile provider base class uses reflection, so we couldn’t just rewrite the feature without reflection. We had to totally recreate it without the ASP.NET profile provider model.

The widget framework

The medium trust issues continued in the widget framework, but only if you used the database provider. Again, this was due to the fact that medium trust environments doesn’t allow for reflection. Basically, we didn’t test the medium trust environment properly – if not at all – prior to release. The JavaScript that pops up the editor has also been tweaked so it now shows correctly in all browsers.

It wasn’t possible to write widgets that performs postbacks or client callbacks. It is now.

Create new user

When a new author was added they couldn't log in. This bug only figured in the XML membership provider when passwords where configured to be hashed in the web.config.

Broken links

In versions earlier than 1.4, the post links generated from a title could contain three hyphens in a row. In 1.4 it no longer did this because it made the URLs prettier and easier to read. However, it broke the old links from external sites. The upcoming release will also not generate URLs with three consecutive hyphens, but it will parse them correctly so no old links will break.

There are many other minor bugs that have been fixed.

New features

It’s not only bug fixes that made it into the upcoming release. Some new features have been added as well.

Filter by APML

As a semantic web freak, this is a feature I’m very proud to introduce to BlogEngine.NET. You can now filter the posts of a blog by your own APML file. An APML file is a prioritized list of your own interests represented in XML. All BlogEngine.NET 1.4+ users have such a file auto generated and it’s called /apml.axd. You only have to enter your blog URL and BlogEngine.NET will then find your APML using auto-discovery like the browser does for RSS feeds. Try it by clicking the APML filter link on the top right of this page.

File upload directories

Files and images uploaded will now be placed in new folders that are named by the year and month. This could be /files/2008/07/example.doc. This will make backup easier.

Use raw HTML editor by default

Some people don’t like the TinyMCE editor or any other editor and prefer to enter their own HTML. Now there is a switch that remembers your preferences and allows you to write your own HTML.

Force SSL in the MetaWeblog API

When you use Windows Live Writer or another editor through BlogEngine.NET’s MetaWeblog API you have always sent your username and password in clear text. This is the normal way that almost every blog platforms use. If you have a server certificate that allows you to run SSL, it is now possible to flip a switch that forces Windows Live Writer to send the data securely to your blog.

Other tweaks

  • Uncategorized posts are now shown in the archive
  • Calendar widget now works the first time it is added
  • Posting from Windows Live Writer now posts in the correct time zone
  • Users can now be edited again from the admin section
  • JavaScript removed from page and placed in blog.js for smaller page sizes
  • hCard microformat added to comments
  • HTTP compression of WebResource.axd (can be switched off)
  • Switch added to prefix post titles with blog name or not (SEO stuff)
  • Performance boost to CSS, image, file and JavaScript handlers by using 304 headers

I’m very sorry that this new release is necessary, because it is due to lack of a longer test phase. I do hope these new features will soften the fall a bit. Remember, if you are running the XML provider in full trust, then you might never have noticed any of the issues and might not need the upgrade. I do hope everybody will upgrade anyway, since it is a more stabile system with some new cool features. It's planned for download in a week.

Imaging a visitor that enters his website URL into a textbox and when he clicks the submit button, you are able to retrieve all kinds of information from the guy. His name, company info, online profiles, interests etc. all this from just a URL. It’s actually pretty easy if the website contains information about FOAF, APML or SIOC documents.

What you have to do is to download the HTML from the website and look for <link> elements in the header that matches FOAF, APML or SIOC type links. Then retrieve the URL to those documents from the href attribute and load it into an XML document. Now you can use XPath to find all the information you need.

Here’s is what a FOAF link element looks like:

<link type="application/rdf+xml" rel="meta" title="FOAF" href="http://example.com/foaf.xml" />

SIOC and APML links uses the same attributes in the same way, so we can use the title attribute to figure out which kind of document it is. All we need is a method that uses regular expressions to retrieve the document URLs from the HTML.

The code

This is a method that finds all the semantic links of a certain type in a HTML string.

private const string PATTERN = "<head.*<link( [^>]*title=\"{0}\"[^>]*)>.*</head>";

private static readonly Regex HREF = new Regex("href=\"(.*)\"", RegexOptions.IgnoreCase | RegexOptions.Compiled);

 

/// <summary>

/// Finds semantic links in a given HTML document.

/// </summary>

/// <param name="type">The type of link. Could be foaf, apml or sioc.</param>

/// <param name="html">The HTML to look through.</param>

/// <returns></returns>

private static Collection<Uri> FindLinks(string type, string html)

{

  MatchCollection matches = Regex.Matches(html, string.Format(PATTERN, type), RegexOptions.IgnoreCase | RegexOptions.Singleline);

  Collection<Uri> urls = new Collection<Uri>();

 

  foreach (Match match in matches)

  {

    if (match.Groups.Count == 2)

    {

      string link = match.Groups[1].Value;

      Match hrefMatch = HREF.Match(link);

 

      if (hrefMatch.Groups.Count == 2)

      {

        Uri url;

        string value = hrefMatch.Groups[1].Value;

        if (Uri.TryCreate(value, UriKind.Absolute, out url))

        {

          urls.Add(url);

        }

      }

    }

  }

 

  return urls;

}

Example

To find all the FOAF links in a page you can write something like this:

using (WebClient client = new WebClient())

{

  string html = client.DownloadString(txtUrl.Text);

  Collection<Uri> col = FindLinks("foaf", html);

 

  foreach (Uri url in col)

  {

    XmlDocument doc = new XmlDocument();

    doc.Load(url.ToString());

    Response.Write(Server.HtmlEncode(doc.OuterXml));

  }

}

If you want to search for APML or SIOC then just replace “foaf” with either “apml” or “sioc” in the method parameter. You might also want to take a look at my experimental FOAF parser class.