Bug 160478 - The Like LO Basic operator does not work correctly if there are certain characters in the string being tested.
Summary: The Like LO Basic operator does not work correctly if there are certain chara...
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: BASIC (show other bugs)
Version:
(earliest affected)
unspecified
Hardware: All All
: medium normal
Assignee: Mike Kaganski
URL:
Whiteboard: target:24.8.0 target:24.2.3
Keywords:
Depends on:
Blocks:
 
Reported: 2024-04-02 11:51 UTC by Vladimir Sokolinskiy
Modified: 2024-04-03 08:53 UTC (History)
1 user (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Vladimir Sokolinskiy 2024-04-02 11:51:10 UTC
Run macro:

Sub TestLike
  Dim s As String
  s="ab" & Chr(10) & "cd"
  Msgbox s Like "a*"
End Sub

Returns False, must be True.

The error occurs when the string being tested contains characters U+000A,
U+000B, U+000C, U+000D.
Comment 1 Rafael Lima 2024-04-02 13:07:39 UTC
Indeed this example returns False.

The method IsLike from the String service (ScriptForge) also returns False.

I'm not sure whether this should return True... but I can't see a reason why not.

The weird thing is that I could not find the help page for the Like operator. It's possibly lacking documentation.

Code pointer here:
SbiExpression::Like in /core/basic/source/comp/exprtree.cxx
Comment 2 Vladimir Sokolinskiy 2024-04-02 13:48:25 UTC
Rafael, thank you for participating in the topic.
Added a link to a bug about the lack of documentation for the Like operator.
Comment 3 Mike Kaganski 2024-04-02 15:49:21 UTC
It must return True here, because LIKE operator, by definition, matches the string against the pattern, not some part of the string, arbitrarily separated by newline characters.

https://gerrit.libreoffice.org/c/core/+/165700
Comment 4 Vladimir Sokolinskiy 2024-04-02 15:53:25 UTC
Mike, thank you for quickly fixing the bug! :)
Comment 5 Commit Notification 2024-04-02 17:47:40 UTC
Mike Kaganski committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/38f731ff67142a423aa6f46dc3e92d094f86ffb1

tdf#160478: fix Basic LIKE operator

It will be available in 24.8.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 6 Commit Notification 2024-04-03 08:53:34 UTC
Mike Kaganski committed a patch related to this issue.
It has been pushed to "libreoffice-24-2":

https://git.libreoffice.org/core/commit/b4abb5ee77c6894cd9a9ef3d5f66e868b591d02c

tdf#160478: fix Basic LIKE operator

It will be available in 24.2.3.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.