IfFound condition is unexpected true on no replace done on selected text because of no selection

IfFound condition is unexpected true on no replace done on selected text because of no selection

6
NewbieNewbie
6

    Sep 22, 2019#1

    Please test this tiny macro on several files (including empty ones) without any text selected.
    The macro DOES NOT CHANGE THE FILE.
    If no text is selected, the GetString should never be executed.
    But it sometimes does and I cannot figure out why/when.

    Code: Select all

    PerlReOn
    Find RegExp SelectText "xsftq"
    Replace All "`"
    IfFound
    GetString "ERROR"
    EndIf
    I'm using UltraEdit Text/Hex Editor (x64) Version 26.20.0.6.

    6,688586
    Grand MasterGrand Master
    6,688586

      Sep 23, 2019#2

      Congratulation! You found a curious bug. I can reproduce this issue with UE for Windows from version 22.00.0.46 to version 26.20.0.6, but not with versions before 20.00. It looks like an undefined behavior caused by a not initialized variable on no Perl regular expression replace executed on selected text because of nothing selected in the active file. I reported this issue by email to IDM support.

      Workaround 1: Do not use a Perl regular expression by removing RegExp.

      Code: Select all

      PerlReOn
      Find SelectText "xsftq"
      Replace All "`"
      IfFound
      GetString "ERROR"
      EndIf
      Workaround 2: Use UltraEdit or Unix regular expression engine by replacing PerlReOn by UltraEditReOn or UnixReOn.

      Code: Select all

      UltraEditReOn
      Find RegExp SelectText "xsftq"
      Replace All "`"
      IfFound
      GetString "ERROR"
      EndIf
      Workaround 3: Run the Perl regular expression replace on selected text only if there is a selection by using IfSel with a matching EndIf.

      Code: Select all

      IfSel
      PerlReOn
      Find RegExp SelectText "xsftq"
      Replace All "`"
      IfFound
      GetString "ERROR"
      EndIf
      EndIf
      Best regards from an UC/UE/UES for Windows user from Austria

      6
      NewbieNewbie
      6

        Sep 23, 2019#3

        Thanks Mofi. I thought I was seeing things.