Page MenuHomePhabricator

zimlib reports an unknown MIME type 65535 error for all articles with a redirect.
Closed, ResolvedPublic

Description

Author: kiranmathewkoshy

Description:
In all zim files, all articles that have a redirect are given the MIME type code of 65535. The problem is, whenever getMimeType() or getPage() is called in zimlib for an article that has a redirect, zimlib throws an "unknown MIME type 65535" error.


Version: unspecified
Severity: critical

Details

Reference
bz51881

Event Timeline

bzimport raised the priority of this task from to Needs Triage.Nov 22 2014, 2:03 AM
bzimport added a project: openZIM-zimlib.
bzimport set Reference to bz51881.

tommi wrote:

It works as expected. The mime type is explicitly set to std::numeric_limits<uint16_t>::max() in redirects. See include/zim/dirent.h line 104.

Users should not call getMimeType or getPage on redirects but use isRedirect first to check weather the article is actually a redirect. The methods getMimeType and getPage do not actually make any sense on redirects.

A improvement would be to change the error message to something more useful but calling getMimeType or getPage on redirects should throw an exception.

kiranmathewkoshy wrote:

Yes, but throwing an error for every redirect article doesn't gain anything.
getMimeType() could return "redirect" and getPage() could return an empty string, and that way, a throw and catch could be avoided.

tommi wrote:

A throw and catch could be avoided, if you just as for isRedirect first. It is just wrong to ask for a mime type or data from a redirect. "getMimeType()" should return a valid mime type and "redirect" is no mime type. Also a redirect has not empty page data. It has no page data at all since it does not make sense. It is just like in databases where there is a NULL value. It is an error if you ask for a value of a column, which do not have a value i.e. NULL.

kiranmathewkoshy wrote:

Isn't it a little ironic that getLibraryMimeType() returns a 65535 without any error, but getMimeType() causes an error ?

tommi wrote:

Ok - bug accepted - getLibraryMimeType should throw an exception also.