public ChildContainerResult filter(ChildContainerResult unfiltered) throws ServerErrorException {
        ByteArrayOutputStream baos = new ByteArrayOutputStream();

        try {
            freenet.client.filter.ContentFilter.FilterStatus status =
                freenet.client.filter.ContentFilter.filter(new ByteArrayInputStream(unfiltered.getData()),
                                                           baos,
                                                           unfiltered.getMimeType(),
                                                           unfiltered.getEncoding(),
                                                           this);

            if (!charsetMatches(status, unfiltered)) {
                throw new ServerErrorException("BUG: Generated output with unexpected "
                                               + "character set. But we caught it :-)");
            }
            if (!status.mimeType.equals(unfiltered.getMimeType())) {
                throw new ServerErrorException("BUG: Generated output with unexpected "
                                               + "mime type. But we caught it :-)");

            }

            byte[] filteredData = baos.toByteArray();

            if (unfiltered.getMimeType().equals("text/html")) {
                // Fix a few specific cases that are mangled.
                filteredData = postProcess(filteredData);
            }
            // NOTE: Replace because the filter might have rewritten stuff.
            return new StaticResult(unfiltered.getEncoding(),
                                    unfiltered.getMimeType(),
                                    unfiltered.getTitle(),
                                    unfiltered.getMetaRefreshSeconds(),
                                    filteredData);

        } catch (UnsafeContentTypeException ucte) {
            ucte.printStackTrace();
            throw new ServerErrorException("BUG: Generated dangerous html(0)??? But we caught it :-)");
        } catch (FilterTrippedException fte) {
            fte.printStackTrace();
            throw new ServerErrorException("BUG: Generated dangerous html(1)??? But we caught it :-)");
        } catch (IOException ioe) {
            ioe.printStackTrace();
            throw new ServerErrorException("BUG: IOException validating page???");
        }
    }