Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    SmartClient 6.0 (with SC Server) Patch for transaction data being applied to dataURL

    In some versions of SmartClient version 6.0, an issue exists whereby when using simple HTTP communication, an inappropriate SmartClient transaction parameter can be added to the target URL.

    Note that:
    - This issue should not occur in the 6.0 LGPL build - only for builds including the optional SmartClient Server functionality.
    - In most cases this patch will not be required, as the transaction parameter on the URL can be safely ignored by the server - the patch is only required for implementations where the server will crash if passed extra params.

    Code:
    //----------------------------------------------------------------------------
    // Isomorphic SmartClient v6.0 patch
    // Purpose: Resolves an issue where when using simple HTTP requests an inappropriate SmartClient 
    // transaction parameter could be added to the target URL.
    // 
    // Applies to SmartClient version 6.0 only
    // *Note: Not required for the SmartClient LGPL version
    //----------------------------------------------------------------------------
    if (window.isc && isc.version.startsWith("6.0/")){
    isc.RPCManager.addClassMethods({
    sendQueue : function (prompt, URL) {
    var transaction = this.currentTransaction;
    this.currentTransaction = null;
    this.queuing = false;
    if (!transaction) {
    this.logWarn("sendQueue called with no current queue, ignoring");return false;
    }
    var request = transaction.operations[0];
    if (!isc.Page.isLoaded()) {
    if (!this.delayingTransactions) isc.Page.setEvent("load", this, isc.Page.FIRE_ONCE,
                                                   "resendDelayedTransactions");
    this.delayingTransactions = true;
    }
    if (this.delayingTransactions) {
    this.delayTransaction(transaction);
    return request;
    }
    transaction.timestamp = new Date().getTime();
    if (!this.onLine && !this.offlinePlayback && this.offlineTransaction) {
    this.offlineTransaction(transaction);
    return request;
    }
    var allClientOnly = true;
    for (var i = 0; i < transaction.operations.length; i++) {
    if (!transaction.operations[i].clientOnly) {
    allClientOnly = false;
    break;
    }
    }
    if (allClientOnly) {
    transaction.allClientOnly = true;
    
    this.delayCall("$39d", [transaction.transactionNum], 0);
    return request;
    }
    URL = transaction.URL = isc.Page.getURL(URL || transaction.URL || this.getActionURL());
    if (!request.useSimpleHttp && transaction.transport != "scriptInclude") {
    URL = this.markURLAsRPC(URL);
    if (transaction.transport == "xmlHttpRequest") URL = this.markURLAsXmlHttp(URL);
    if (document.domain != location.hostname) URL = this.addDocumentDomain(URL);
    
    URL = this.addParamsToURL(URL, {isc_tnum: transaction.transactionNum});
    }
    prompt = transaction.prompt = ((transaction.showPrompt == null || transaction.showPrompt) ? 
    (prompt || transaction.prompt || this.defaultPrompt) : null);
    if (prompt) this.doShowPrompt(transaction, prompt);
    var transactionParams = {};
    var haveParams = false;
    for (var i = 0; i < transaction.operations.length; i++) {
    var rpcRequest = transaction.operations[i];
    var params = rpcRequest.params;
    var queryParams = rpcRequest.queryParams;
    var origParams = params;
    if (queryParams && isc.isAn.Object(queryParams)) {
    URL = transaction.URL = this.addParamsToURL(URL, queryParams);
    }
    if (params && haveParams)
    this.logWarn("Multiple RPCRequests with params attribute in one transaction - merging");
    if (params) {
    if (isc.isA.String(params)) {
        if (window[params]) params = window[params]; // component
        else if (isc.Canvas.getForm(params)) params = isc.Canvas.getForm(params); // native form
        else {
            this.logWarn("RPCRequest: " + isc.Log.echo(rpcRequest) 
                + " was passed a params value: " + params 
                + " which does not resolve to a component or a native"
                + " form - request to server will not include these params");
            params = null;
        }   
    }
    if (isc.isA.Class(params)) {
        if (params.getValues) params = params.getValues();
        else {
            this.logWarn("RPCRequest: " + isc.Log.echo(rpcRequest)
                + " was passed an instance of class " + params.getClassName()
                + " (or a global ID that resolved to this class)"
                + " - this class does not support the getValues() method - request to"
                + " server will not include these params");
        }
    }
    if (params && !isc.isAn.Object(params)) {
        this.logWarn("params value: " + origParams + " for RPCrequest: " 
            + isc.Log.echo(rpcRequest) + " resolved to non-object: " 
            + isc.Log.echo(params) + " - request to server will not include these params");
        params = null;
    }
    if (params) {
        isc.addProperties(transactionParams, params);
        haveParams = true;
    }
    }
    }
    if (this.logIsInfoEnabled()) {
    this.logInfo("sendQueue[" + transaction.transactionNum + "]: " +
    transaction.operations.length + " RPCRequest(s); transport: " +
             transaction.transport + "; target: " + URL);
    }
    transaction.sendTime = isc.timeStamp();
    transaction.changed();
    transaction.callback = "isc.RPCManager.performTransactionReply(transactionNum,results,wd)";
    var scs = isc.SCServerEditorActionMethods != null;
    if (scs && request.directSubmit) {
    isc.Comm.generateJSCallback(transaction);
    var form = request.submitForm;
    var domForm = form.getForm();
    if (form.getItem("_transaction") != null && 
    isc.isA.HiddenItem(form.getItem("_transaction"))) 
    { 
    form.setValue("_transaction", this.serializeTransaction(transaction)); 
    this.logInfo("Direct submit assigning request data to hidden field instead of" + 
    " submitting as GET request"); 
    domForm.action = this.addParamsToURL(URL, transactionParams); 
    } else {
    if (request.useSimpleHttp) {
    domForm.action = this.addParamsToURL(URL, transactionParams); 
    transaction.$387 = true;
    } else {
    domForm.action = this.transactionAsGetRequest(transaction,null, transactionParams);
    }
    }
    this.$39a(transaction);
    if (request.target) {
    if (request.target != window) domForm.target = request.target;
    form.submitForm();
    } else {
    var frame = isc.Comm.getTargetableFrame(request.prompt);
    domForm.target = frame.getName();
    transaction.$ch = frame;
    frame.draw(form.getID() + ".submitForm()");
    }
    } else if (scs && request.downloadResult) {
    if (!window.name) window.name = isc.timeStamp();
    var target = transaction.download_filename;
    if (request.downloadToNewWindow == false || 
    (request.downloadToNewWindow == null && request.exportFilename)) {
    var target = window.name;
    }
    if (request.$38j) {
    this.clearTransaction(transaction);
    transaction.transactionRequest = this.transactionAsGetRequest(transaction, URL, transactionParams);
    return transaction.transactionRequest;
    }
    var params = isc.addProperties(transactionParams, 
    {_transaction:this.serializeTransaction(transaction), protocolVersion:"1.0"});
    transaction.$387 = true;
    this.$39a(transaction);
    transaction.$ch = isc.Comm.sendHiddenFrame({
    URL: URL, 
    httpMethod: request.httpMethod,
    httpHeaders: request.httpHeaders,
    contentType: request.contentType,
    fields: params,
    target: target,
    transactionNum: transaction.transactionNum,
    transaction:transaction
    });
    } else {
    var params = transactionParams;
    var transport = transaction.transport,
    transportMethodName = "send" + (transport.substring(0,1).toUpperCase()) + transport.substring(1);
    if (isc.Comm[transportMethodName] == null) {
    this.logWarn("Attempt to send transaction with specified transport '"
                 + transaction.transport + "' failed - unsupported transaction type.");
    return;
    }
    this.$39a(transaction);
    isc.RPCManager.$410.push(transaction.transactionNum);
    transaction.transactionRequest = isc.Comm[transportMethodName]({
    URL: URL, 
    httpMethod: request.httpMethod,
    contentType: request.contentType,
    httpHeaders: request.httpHeaders,
    bypassCache: request.bypassCache,
    data: request.useSimpleHttp ? request.data : null,
    fields: params, 
    target: request.target,
    // valid only for scriptInclude
    callbackParam: request.callbackParam,
    transport: transaction.transport,
    blocking: request.blocking,
    useSimpleHttp:request.useSimpleHttp,
    transactionNum: transaction.transactionNum,
    transaction: transaction
    });
    }
    return request;
    }
    });
    
    } else if (window.isc) {
      isc.Log.logWarn("Patch for SmartClient 6.0 included in this application. " +
                "You are currently running SmartClient verion '"+ isc.version + 
                "'. This patch is not compatible with this build and will have no effect. " +
                "It should be removed from your application source.");
    
    }
    Last edited by Isomorphic; 7 Dec 2007, 17:39.
Working...
X