ソースを参照

fcl-db: sqldb: when parsing SQL end of /* comment */ is not detected if ends with **/. Bug #30171

git-svn-id: trunk@33761 -
lacak 9 年 前
コミット
33d48897d7

+ 7 - 4
packages/fcl-db/src/base/dsparams.inc

@@ -257,14 +257,17 @@ begin
         if p^='*' then // /* */ comment
         begin
           Result := True;
-          repeat
-            Inc(p);
+          Inc(p);
+          while p^ <> #0 do
+          begin
             if p^='*' then // possible end of comment
             begin
               Inc(p);
               if p^='/' then Break; // end of comment
-            end;
-          until p^=#0;
+            end
+            else
+              Inc(p);
+          end;
           if p^='/' then Inc(p); // skip final /
         end;
       end;

+ 2 - 0
packages/fcl-db/tests/testbasics.pas

@@ -145,6 +145,8 @@ begin
   // Bracketed comment
   AssertEquals(     'select * from table where id=/*comment :c*/$1-$2',
     Params.ParseSQL('select * from table where id=/*comment :c*/:a-:b', True, True, True, psPostgreSQL));
+  AssertEquals(     'select * from table where id=/*comment :c**/$1-$2',
+    Params.ParseSQL('select * from table where id=/*comment :c**/:a-:b', True, True, True, psPostgreSQL));
   // Consecutive comments, with quote in second comment
   AssertEquals(     '--c1'#10'--c'''#10'select '':a'' from table where id=$1',
     Params.ParseSQL('--c1'#10'--c'''#10'select '':a'' from table where id=:id', True, True, True, psPostgreSQL));