Bug 696662

Summary: Streams associated with content: URIs are not reliably read
Product: MuPDF Reporter: Marc K. <morckx>
Component: appsAssignee: MuPDF bugs <mupdf-bugs>
Status: RESOLVED FIXED    
Severity: normal CC: robin.watts
Priority: P4    
Version: master   
Hardware: Android Phone   
OS: Android   
Customer: Word Size: ---
Attachments: [PATCH] Poperly read streams associated with content: URIs

Description Marc K. 2016-03-16 14:05:11 UTC
Created attachment 12393 [details]
[PATCH] Poperly read streams associated with content: URIs

E.g. attachments from K-9 Mail (recent builds) cannot be opened because InputStream.available() used MuPDFActivity.java always reports 0 for streams that have no buffered data and therefore cannot be read without blocking. The attached patch fixes the problem.
Comment 1 Robin Watts 2016-07-19 01:58:40 UTC
Fixed in:

commit 537a467dfd6392d70624805943ac65182ec881b4
Author: Robin Watts <robin.watts@artifex.com>
Date:   Mon Jul 18 12:11:45 2016 +0100

    Bug 696662: Android viewer: data from URI stream fix.

    Apparently, if MuPDF is invoked on a content stream that
    comes from a URI, then is.available() can report 0 bytes
    (as there is no data buffered). Use a modified formulation
    that reads as much data as possible from the stream into
    a BufferedOutputStream and then makes a byte array from that.

    Would be nicer if the core could actually read from the
    stream directly, perhaps, but that can wait for the new JNI
    based version.

    Thanks to Marc K for identifying the problem and supplying
    the patch.