Modify

Opened 7 years ago

Closed 4 years ago

#3563 closed Bug (Fixed)

Function _IEBodyReadText() from IE.au3 needs to check .innerText is a valid property

Reported by: John.D.Rainbow@… Owned by: mLipok
Milestone: Component: AutoIt
Version: 3.3.15.0 Severity: None
Keywords: _IEBodyReadText, .innerText Cc:

Description

To avoid this (albeit infrequent) problem:

Return SetError($_IESTATUS_Success, 0, $oObject.document.body.innerText)
Return SetError($_IESTATUS_Success, 0, $oObject.document.body^ ERROR

which is related to function _IEBodyReadText() from IE.au3
the missing property checking (similar as done in other IE.au3 functions which need it) is respectfully asked to be included with the correction offered for this function as follows for your consideration please:

Func _IEBodyReadText(ByRef $oObject)
    If Not IsObj($oObject) Then
        __IEConsoleWriteError("Error", "_IEBodyReadText", "$_IESTATUS_InvalidDataType")
        Return SetError($_IESTATUS_InvalidDataType, 1, 0)
    EndIf
    If Not __IEIsObjType($oObject, "browserdom") Then
        __IEConsoleWriteError("Error", "_IEBodyReadText", "$_IESTATUS_InvalidObjectType", "Expected document element")
        Return SetError($_IESTATUS_InvalidObjectType, 1, 0)
    EndIf

    ;------------------------------------------------------------------------------------------
    ; Check to verify that the document body object has an innerText property, if not, skip trying to return its contents
    ;
    ; Setup internal error handler to Trap COM errors, turn off error notification,
    ;     check object property validity, set a flag and reset error handler and notification
    ;
    Local $bIsInnerText = True
    ; Trap COM errors and turn off error notification
    $bStatus = __IEInternalErrorHandlerRegister()
    If Not $bStatus Then __IEConsoleWriteError("Warning", "_IEBodyReadText", _
            "Cannot register internal error handler, cannot trap COM errors", _
            "Use _IEErrorHandlerRegister() to register a user error handler")
    ; Turn off error notification for internal processing
    $iNotifyStatus = _IEErrorNotify() ; save current error notify status
    _IEErrorNotify(False)

    ; Check conditions to verify that the property exists
    If $bIsInnerText Then
        $sTmp = $oObject.document.body.innerText ; Is .innerText a valid property?
        If @error Then $bIsInnerText = False
    EndIf

    ; restore error notify
    _IEErrorNotify($iNotifyStatus) ; restore notification status
    __IEInternalErrorHandlerDeRegister()
    ;------------------------------------------------------------------------------------------

    If $bIsInnerText Then   
        Return SetError($_IESTATUS_Success, 0, $oObject.document.body.innerText)
    Else
        __IEConsoleWriteError("Error", "_IEBodyReadText", "$_IESTATUS_InvalidObjectType", "Expected innerText element")
        Return SetError($_IESTATUS_InvalidObjectType, 1, 0)     
    EndIf
        
EndFunc   ;==>_IEBodyReadText


Attachments (0)

Change History (4)

comment:1 Changed 6 years ago by mLipok

  • Component changed from AutoIt to Standard UDFs
  • Owner set to mLipok
  • Status changed from new to assigned
  • Version changed from 3.3.14.0 to 3.3.15.0

There are working people on rewriting the entire UDF, behind the scenes, and the new version already have this problem resolved.

For now please visit:
https://www.autoitscript.com/forum/topic/177783-example-proper-usage-ieau3-udf-with-autoit-v3314x/

This ticket will be closed when new IE.au3 will be released.

comment:2 Changed 6 years ago by Jpm

speedup the rewriting ...

comment:3 Changed 4 years ago by Jpm

Perhaps a little speedup ...

comment:4 Changed 4 years ago by mLipok

  • Component changed from Standard UDFs to AutoIt
  • Resolution set to Fixed
  • Status changed from assigned to closed

Guidelines for posting comments:

  • You cannot re-open a ticket but you may still leave a comment if you have additional information to add.
  • In-depth discussions should take place on the forum.

For more information see the full version of the ticket guidelines here.

Add Comment

Modify Ticket

Action
as closed The owner will remain mLipok.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.