Modify

Opened 14 years ago

Closed 14 years ago

#1549 closed Bug (Fixed)

Call to _SQLite_Escape causes exception abend in certain circumstances

Reported by: jmansheim@… Owned by: Jpm
Milestone: 3.3.7.0 Component: Standard UDFs
Version: 3.3.6.0 Severity: None
Keywords: SQLite _SQLite_Escape dll Cc:

Description

I have a program which parses html pages and inserts the data into a SQLite database. In certain circumstances, when I parse sections of text, _SQLite_Escape abends with an exception error. AutoIt reports an Exit Code of -1073741819.

Program Code:

#include <IE.au3>
#include <SQLite.au3>
#include <SQLite.dll.au3>

_SQLite_Startup ()

$lawWindow = _IECreate ()
_IENavigate($lawWindow, "file://I:\laws\testbadfile.htm", 1)
$fullText = _IEBodyReadText ($lawWindow)
$escapedText = _SQLite_Escape($fullText) 

Two files are attached, one which does not produce the error (testgoodfile.htm) and one which does produce the error (testbadfile.htm). Be sure that you change the path to the file in the _IENavigate function call.

The SQLite.au3 version included with AutoIt 3.3.3.0 works fine on both files and all others I have seen.

Any SQLite.au3 versions includedwith AutoIt 3.3.4.0 or later do not work on both files and the success is intermitant.

I believe the error is happening in the function
_ _SQLite_Utf8StructToString during this call:

$aResult = DllCall("Kernel32.dll", "int", "MultiByteToWideChar", "uint", 65001, "dword", 0, "ptr", DllStructGetPtr($tText), "int", -1, _
						"wstr", DllStructGetPtr($tWstr), "int", $aResult[0])

Attachments (1)

testfiles.zip (68.2 KB) - added by jmansheim@… 14 years ago.
Contains a file which creates and abend situation (testbadfile.htm) and which does not create an abend (testgoodfile.htm)

Download all attachments as: .zip

Change History (5)

Changed 14 years ago by jmansheim@…

Contains a file which creates and abend situation (testbadfile.htm) and which does not create an abend (testgoodfile.htm)

comment:1 Changed 14 years ago by anonymous

Thank you for reporting. I'll look at this more closely.

In the meantime, you can use the following functions, that may someday replace _SQLite_Escape and _SQLite_Encode.

Func X($s)
	Return ("'" & StringReplace($s, "'", "''", 0, 1) & "'")
EndFunc   ;==>X

Func XX($s)
	Return (",'" & StringReplace($s, "'", "''", 0, 1) & "'")
EndFunc   ;==>XX

Func Y($s)
	Return ("X'" & Hex($s) & "'")
EndFunc   ;==>Y

Func YY($s)
	Return (",X'" & Hex($s) & "'")
EndFunc   ;==>YY

X($str) is _SQLite_Escape($str)
Y($bin) is _SQLite_Encode($bin)
XX and YY are useful for subsequent parameters: they prepend a comma to output of X() and Y().
This makes the use very compact and readable:

$err = _SQLite_Exec($hdl, "insert into T (a, b, c) values ("&X($text1)&XX($str2)&XX($s3)&");")
or using another style
$err = _SQLite_Exec($hdl, "insert into T (a, b, c) values (" & _
                                         X($text1) & _
                                        XX($str2) & _
                                        XX($s3) & _
                                        ");")

These short function names are mine, but if they ever make it in the SQLite UDF they will likely have less ambiguous names and include error checking...

comment:2 Changed 14 years ago by jchd

(I left anonymous be mistake)

comment:3 Changed 14 years ago by Jpm

I assume you mean 3.3.0.0 and not 3.3.3.0. I need to do some archeology to found out when the regression occured.
Anyway will be fixed next beta
Thanks

comment:4 Changed 14 years ago by Jpm

  • Milestone set to 3.3.7.0
  • Owner changed from Gary to Jpm
  • Resolution set to Fixed
  • Status changed from new to closed

Fixed by revision [5743] in version: 3.3.7.0

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 Jpm.
Author


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

 
Note: See TracTickets for help on using tickets.