mirror of
https://github.com/HeidiSQL/HeidiSQL.git
synced 2026-03-13 09:24:25 +08:00
Make regular expression safe against huge length/set attributes of column types. Fixes issue #1786.
This commit is contained in:
@@ -11,7 +11,7 @@ interface
|
||||
uses
|
||||
Classes, SysUtils, Graphics, GraphUtil, ClipBrd, Dialogs, Forms, Controls, ComCtrls, ShellApi, CheckLst,
|
||||
Windows, Contnrs, ShlObj, ActiveX, VirtualTrees, SynRegExpr, Messages,
|
||||
Registry, SynEditHighlighter, DateUtils, Generics.Collections, AnsiStrings,
|
||||
Registry, SynEditHighlighter, DateUtils, Generics.Collections, StrUtils, AnsiStrings,
|
||||
mysql_connection, mysql_structures;
|
||||
|
||||
type
|
||||
@@ -2820,13 +2820,18 @@ begin
|
||||
rx := TRegExpr.Create;
|
||||
rx.ModifierS := False;
|
||||
rx.ModifierM := True;
|
||||
rx.Expression := '^\s+[`"]([^`"]+)[`"]\s(\w+)(.*)';
|
||||
rx.Expression := '^\s+[`"]([^`"]+)[`"]\s(\w+)';
|
||||
rxCol := TRegExpr.Create;
|
||||
rxCol.ModifierI := True;
|
||||
if rx.Exec(CreateTable) then while true do begin
|
||||
if not Assigned(Columns) then
|
||||
break;
|
||||
ColSpec := rx.Match[3];
|
||||
ColSpec := '';
|
||||
for i:=rx.MatchPos[2]+rx.MatchLen[2] to Length(CreateTable) do begin
|
||||
if CharInSet(CreateTable[i], [#13, #10]) then
|
||||
break;
|
||||
ColSpec := ColSpec + CreateTable[i];
|
||||
end;
|
||||
|
||||
// Strip trailing comma
|
||||
if (ColSpec <> '') and (ColSpec[Length(ColSpec)] = ',') then
|
||||
|
||||
Reference in New Issue
Block a user