ykhuda / alivepdf

Automatically exported from code.google.com/p/alivepdf
0 stars 0 forks source link

Security error #3769 breaks navigateToUrl() while trying to save PDF #369

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Trying to save grid data in a PDF file.
2. Adobe flash security sand box error appears and application gets hanged.

What is the expected output? What do you see instead?
Ideally the PDF gets created and opened instead error is coming.

What version of the product are you using? On what operating system?
latest version.

Please provide any additional information below.
Adobe has blocked custom headers from navigateToUrl() when the URLRequest is a 
POST. It no longer works in Flash 13.0.0.214

Original issue reported on code.google.com by ahmed.na...@gmail.com on 8 Jul 2014 at 10:36

GoogleCodeExporter commented 9 years ago
Please provide a solution to fix this issue?

Original comment by ahmed.na...@gmail.com on 8 Jul 2014 at 10:36

GoogleCodeExporter commented 9 years ago
The solution is relatively simple, actually.

Open "/src/org/alivepdf/pdf/PDF.as" and replace the save method (line 3473, at 
least in version "AlivePDF 0.1.5 RC") with the following.

Note that the only modifications are to the "case Method.REMOTE :" block; the 
rest is untouched.

public function save ( method:String, url:String='', 
downloadMethod:String='inline', fileName:String='generated.pdf', 
frame:String="_blank" ):*
{
    dispatcher.dispatchEvent( new ProcessingEvent ( ProcessingEvent.STARTED ) );
    var started:Number = getTimer();
    finish();
    dispatcher.dispatchEvent ( new ProcessingEvent ( ProcessingEvent.COMPLETE, getTimer() - started ) );
    buffer.position = 0;
    var output:* = null;

    switch (method)
    {
        case Method.LOCAL : 
            output = buffer;
            break;  

        case Method.BASE_64 : 
            output = Base64.encode64 ( buffer );
            break;

        case Method.REMOTE :
            //Modified on 2014.07.21 to resolve a recent change to Flash Player
            //(introduced in version 13.0.0.214) that broke AlivePDF. As of this version of
            //Flash, the original AlivePDF code produced the following runtime error:
            //SecurityError: Error #3769: Security sandbox violation: Only simple headers can be used with navigateToUrl() or sendToUrl().
            //
            //For details, and the solution, see:
            //https://forums.adobe.com/message/6398364#6398364

            var bytesTemp : ByteArray = buffer;
            var sendRequest:URLRequest =new URLRequest(url+'?name='+fileName+'&method='+downloadMethod);
            sendRequest.method = URLRequestMethod.POST;
            sendRequest.data = bytesTemp;
            navigateToURL(sendRequest, '_blank');

            break;

        default:
            throw new Error("Unknown Method \"" + method + "\"");
    }

    return output;
}

You may need to modify the following line to work with your particular 
server-side implementation, though:

var sendRequest:URLRequest =new 
URLRequest(url+'?name='+fileName+'&method='+downloadMethod);

BAM! Solved! :)

Original comment by indietor...@gmail.com on 21 Jul 2014 at 7:12

GoogleCodeExporter commented 9 years ago
Already tried this.. but no luck.... with above code changes the binary data 
i.e buffer is not passing to the server side script.. did this worked for you?

Original comment by ahmed.na...@gmail.com on 22 Jul 2014 at 8:47

GoogleCodeExporter commented 9 years ago
Fixed in PDF.as

Also on server side, you need to replace $GLOBALS["HTTP_RAW_POST_DATA"]
by: file_get_contents('php://input')

Original comment by cgauth...@gmail.com on 28 Feb 2015 at 3:23

GoogleCodeExporter commented 9 years ago
This issue was closed by revision r293.

Original comment by cgauth...@gmail.com on 28 Feb 2015 at 3:23