joomla/joomla-cms — pull request #4001 by nikosdion (2014-07-27 10:06:33+00:00)
Title: [#33340] vCard not downloading with cache activated

Joomla! Issue Tracker item [#33340](http://joomlacode.org/gf/project/joomla/tracker/?action=TrackerItemEdit&tracker_item_id=33340&start=0)

# Executive summary

Downloading a vCard from com_contacts returns a document in text/html encoding instead of text/directory. Even when it's fixed in the View, once the cache is turned on Joomla! still returns the data in text/html encoding.

# Problem tracking

There are two bugs in Joomla!.

The first bug is in com_contacts itself. The code is using $document->setMetaData instead of $document->setMimeEncoding to set the content type, resulting in the document not having the correct MIME encoding.

The second bug is missing functionality in JCache, namely the getWorkarounds and setWorkarounds methods. even though we cache all header information of the document we fail to save and restore the MIME encoding. This bug has far reaching consequences to any view returning data other than text/html including but not limited to vCard, RSS, Atom, CSS, Javascript, JSON and plain text. The core components only return HTML, RSS and Atom. Nobody spotted the bug because newsfeed clients will happily parse an RSS/Atom feed no matter the MIME encoding. However, this is a bug known for a long time to 3PDs who return non-HTML data, e.g. XML or JSON. This simple patch fixes this bug by storing the MIME encoding into the cache, like we should be doing all along.