Download it now!
Bug 130863 - AUTO-REDACT: Disable 'Case Sensitive' checkbox + 'Whole word' checkbox when the 'Regular expression' option is selected
Summary: AUTO-REDACT: Disable 'Case Sensitive' checkbox + 'Whole word' checkbox when t...
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
6.4.0.3 release
Hardware: All All
: medium enhancement
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: Redaction
  Show dependency treegraph
 
Reported: 2020-02-22 10:29 UTC by guser
Modified: 2020-09-11 06:36 UTC (History)
7 users (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 guser 2020-02-22 10:29:31 UTC
Description:
When set regular expression in Auto-Redact and disable Case Sensitive checkbox, text match is always case sensitive.

Steps to Reproduce:
1. Open AutoRedact dialog
2. Add Target with regular expression and uncheck Case Sensitive

Actual Results:
Case sensitive settings is ignored with regular expression.

Expected Results:
Don't ingnore Case sensitive setting with regular expression.


Reproducible: Always


User Profile Reset: No



Additional Info:
Version: 6.4.0.3 (x64)
Build ID: b0a288ab3d2d4774cb44b62f04d5d28733ac6df8
CPU threads: 4; OS: Windows 10.0 Build 18362; UI render: default; VCL: win; 
Locale: sk-SK (sk_SK); UI-Language: en-US
Calc: threaded
Comment 1 Muhammet Kara 2020-03-11 11:36:43 UTC
Yes, it is. That's how regex works. You may search on the web to see how you can work-around this. One example out of many search results: https://stackoverflow.com/questions/9655164/regex-ignore-case-sensitivity

This is not a bug in my POV.

On a second thought, I think it might be a good idea to disable the checkbox when regex option is selected, to prevent confusion on the users' side.
Comment 2 Muhammet Kara 2020-03-11 11:40:10 UTC
Also putting a tooltip on the disabled checkbox would be nice, I think.
Comment 3 guser 2020-03-16 05:52:47 UTC
Yes, that regular expression works. So there simple solution, when check Case sensitive, add global flag to regular expression. This solution is used in Find dialog in all LibreOffice apps. For example: open Find dialog in Writer. There are Regular Expression and Case sensitive chceck box and works as expected.
Comment 4 Julien Nabet 2020-07-22 11:44:50 UTC
On pc Debian x86-64 with master sources updated today, I gave it a try.
When choosing regexp, it doesn't disable "Whole words only" or "Match case".

When using Find/Replace, enabling regexp checkbox disables "Whole words only".

Heiko/Xisco: should we do the same in Autoredact as Find/Replace?

Also, it would seem more logical to disable "Match case" when regexp selected in both UI since the regexp option should consider only the regexp entered by the user.
Indeed, let's consider these situations with regexp entry:
- we put a regexp which includes case insensitive + we check "Match case"
- we put a regexp which includes case sensitive + we uncheck "Match case"
What should be the result in these?
Comment 5 Heiko Tietze 2020-07-22 12:29:16 UTC
(In reply to Julien Nabet from comment #4)
> When choosing regexp, it doesn't disable "Whole words only" or "Match case".
> Also, it would seem more logical to disable "Match case" ...

Don't see why RegEx should take whole words or case sensitivity into account since you may specify it explicitly. So yes, disable it please.
Comment 6 Julien Nabet 2020-07-22 13:44:34 UTC
https://gerrit.libreoffice.org/c/core/+/99227
Comment 7 Commit Notification 2020-07-22 16:57:33 UTC
Julien Nabet committed a patch related to this issue.
It has been pushed to "master":

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

tdf#130863: autoredact, disable useless checkboxes for regex

It will be available in 7.1.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 8 Julien Nabet 2020-07-22 17:00:45 UTC
cherry-pick for 7.0 waiting for review here:
https://gerrit.libreoffice.org/c/core/+/99201
Comment 9 Commit Notification 2020-07-30 10:51:31 UTC
Julien Nabet committed a patch related to this issue.
It has been pushed to "libreoffice-7-0":

https://git.libreoffice.org/core/commit/2d2d9e65104f0d6a1ebaed69fa604905be401438

tdf#130863: autoredact, disable useless checkboxes for regex

It will be available in 7.0.1.

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 10 guser 2020-08-04 05:40:56 UTC
Please see my 1st and 4th comment. When I want to use case sensitive search in regexp with global flag, case sensitive checkbox is required. This solution works in all Find dialog in all LibreOffice apps.
Only Auto-redcat feature has bug - when I use regexp, case sensitive search is ignored. Don't disable this checkbox, only add global flag to regexp, when regexp is selected.
Comment 11 guser 2020-08-04 05:42:48 UTC
Sorry, no 4th, but 3rd comment are my.
Comment 12 Julien Nabet 2020-08-04 07:51:00 UTC
I personally prefer disabling these checkboxes when using regexp since regexp have all the prerequisites to indicate whole word or upper/lowercase.

Now if somoneone wants to revert the patch or change this again, don't hesitate too but I won't be this guy since I disagree.
Comment 13 guser 2020-08-04 10:54:23 UTC
Many apps which supports regexp has this checkbox to control global flag, beside to use inline flag. Is confused, when in some dialogs in LibreOffice case sensitive search works, and in other dialog, not. In my first comment I wrote about bug, not to disable checkbox.
It's better to solve problem, not to remove feature.
Comment 14 Julien Nabet 2020-08-04 11:01:12 UTC
(In reply to guser from comment #13)
> Many apps which supports regexp has this checkbox to control global flag,
> beside to use inline flag. Is confused, when in some dialogs in LibreOffice
> case sensitive search works, and in other dialog, not.
I agree with this part.

> In my first comment I
> wrote about bug, not to disable checkbox.
> It's better to solve problem, not to remove feature.
But I still think the best is to disable checkbox in case of regexp and would like to see them disable in all dialogs when regexp is used.

In your case, how do you respond to comment 3
"
let's consider these situations with regexp entry:
- we put a regexp which includes case insensitive + we check "Match case"
- we put a regexp which includes case sensitive + we uncheck "Match case"
What should be the result in these?
"
?
Comment 15 guser 2020-08-04 11:57:53 UTC
When user check Match case, add global flag i, when uncheck, remove flag. This solution is in other LibreOffice dialogs and apps. When user add inline flag, then is evaluated with regexp engine.
In other words: checkbox adds only global flag, you don't analyze regexp.
Comment 16 Julien Nabet 2020-08-04 12:08:03 UTC
(In reply to guser from comment #15)
> When user check Match case, add global flag i, when uncheck, remove flag.
> This solution is in other LibreOffice dialogs and apps. When user add inline
> flag, then is evaluated with regexp engine.
> In other words: checkbox adds only global flag, you don't analyze regexp.
If I understand well your last sentence it means that even if I checked regexp checbox, if there's one of the other checkboxes enabled (Case match or word only), regexp checkbox whereas it's enabled isn't taken into account?
If yes, it's a pb.

But it doesn't fit with your previous statement:" When user add inline
flag, then is evaluated with regexp engine".

I think that someone who chooses regexp knows what he does and doesn't need extra flags. Moreover, as indicated in my previous comment regexp can contain opposite info with flags. That's why I prefer disabling the flag checkboxes when regexp.
+ it would be better to change the other dialogs to follow this rule.
Comment 17 guser 2020-08-04 12:55:01 UTC
Please try this: use Find & Replace dialog in Writer (Edit > Find & Replace). This solution is normal feature like in other apps. Regexp has two options to set case sensitive: global flag for whole regexp and inline flag for partially pattern.
Match case only control global flag, not regexp pattern.
Comment 18 Julien Nabet 2020-08-04 13:01:10 UTC
(In reply to guser from comment #17)
> Please try this: use Find & Replace dialog in Writer (Edit > Find &
> Replace). This solution is normal feature like in other apps. Regexp has two
> options to set case sensitive: global flag for whole regexp and inline flag
> for partially pattern.
> Match case only control global flag, not regexp pattern.

I understood but IMHO this should be too removed to be like Auto-redact dialog is now. Again when regexp, since uppercase/whole word can be controlled by regexp, these checkboxes should be disabled.
Of course, if regexp checkbox isn't enabled, these 2 other checkboxes should be enabled and taken into account.
Comment 19 guser 2020-08-04 15:04:45 UTC
Whole word can be disabled like in other Find dialog. But removing case sensitive option is bad idea. When I need write quick (simple) regexp, this checkbox make job easier. I don't need write inline flag.
With meta character I control pattern case sensitive and with checkbox I control literal character case sensitive.
Comment 20 Julien Nabet 2020-08-04 15:09:53 UTC
(In reply to guser from comment #19)
> Whole word can be disabled like in other Find dialog. But removing case
> sensitive option is bad idea. When I need write quick (simple) regexp, this
> checkbox make job easier. I don't need write inline flag.
> With meta character I control pattern case sensitive and with checkbox I
> control literal character case sensitive.

I don't think regexp should be mixed with these flags because as indicated previously:
"
let's consider these situations with regexp entry:
- we put a regexp which includes case insensitive + we check "Match case"
- we put a regexp which includes case sensitive + we uncheck "Match case"
What should be the result in these?
"
The goal is to avoid confusion instead of being potentially in a clumsy situation.
Comment 21 guser 2020-08-05 05:13:09 UTC
Ok, I understand. Then unify regexp using in all dialogs.
Comment 22 Julien Nabet 2020-08-05 12:42:30 UTC
(In reply to guser from comment #21)
> Ok, I understand. Then unify regexp using in all dialogs.

I submitted this patch https://gerrit.libreoffice.org/c/core/+/100169
Don't know if there is more to do.

Heiko/Xisco: I put you in cc but perhaps we should ping Olivier since doc may be impacted?
Comment 23 Heiko Tietze 2020-08-05 12:50:26 UTC
(In reply to Julien Nabet from comment #22)
> Heiko/Xisco: I put you in cc but perhaps we should ping Olivier since doc
> may be impacted?

See my comment 5 (maybe I'm wrong). Improvements to the help are always welcome.
Comment 24 Julien Nabet 2020-08-05 13:04:18 UTC
Olivier: put you in cc so you got the information of this change of behaviour.
Comment 25 Julien Nabet 2020-08-05 14:04:08 UTC
Cor/Eike: I noticed my patch https://gerrit.libreoffice.org/c/core/+/100169 failed with on gerrit:
FAIL: test_tdf44398_find_replace_regexp_string (tdf44398.tdf44398)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/tdf/lode/jenkins/workspace/lo_gerrit/Config/linux_clang_dbgutil_64/sc/qa/uitest/search_replace/tdf44398.py", line 90, in test_tdf44398_find_replace_regexp_string
    self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), " Var Number A")
AssertionError: ' V a r N u m b e r A' != ' Var Number A'
-  V a r N u m b e r A
?   - -   - - - - -
+  Var Number A
(See https://ci.libreoffice.org/job/gerrit_linux_clang_dbgutil/65620/console)

Does it mean regexp engine doesn't work here?
Indeed, the test contains:
     70         xDialog = self.xUITest.getTopFocusWindow()
     71         searchterm = xDialog.getChild("searchterm")
     72         searchterm.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
     73         searchterm.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
     74         searchterm.executeAction("TYPE", mkPropertyValues({"TEXT":"([A-Z])"}))
     75         replaceterm = xDialog.getChild("replaceterm")

So it's not [A-Z][a-z], it should take account only on letters with uppercase.

Remark: I can't reproduce the pb locally even why trying "make sc.check" or "make sc.slowcheck"
Comment 26 Eike Rathke 2020-08-05 21:01:47 UTC
@Julien: if the checkbox is disabled the test can't set it to case sensitive so the test fails.

However, IMHO disabling the checkbox in the general F&R dialog is unfortunate, if not wrong. Not many know the regex (?-i) flag (or other flags for that matter) and matching case sensitive regex is unnecessarily complicated this way.

Someone knowing and using the flag can easily figure out what the meaning of the checkbox is and that the default is case insensitive (checkbox unchecked). If flags are set in the regex itself then the flags override the global setting anyway.

Furthermore, for the same reason I consider the already applied changes (disabling checkbox in redact dialog and keeping the default case sensitive) to be wrong. The logic should be the same as in the F&R dialog, default case insensitive and the global flag actually be set accordingly.

I suggest to not do that follow-up change and correct the previous changes.
Comment 27 Commit Notification 2020-08-05 21:43:44 UTC
Julien Nabet committed a patch related to this issue.
It has been pushed to "master":

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

Revert "tdf#130863: autoredact, disable useless checkboxes for regex"

It will be available in 7.1.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 28 Julien Nabet 2020-08-05 21:46:34 UTC
(In reply to Eike Rathke from comment #26)
> @Julien: if the checkbox is disabled the test can't set it to case sensitive
> so the test fails.
> ...
> Furthermore, for the same reason I consider the already applied changes
> (disabling checkbox in redact dialog and keeping the default case sensitive)
> to be wrong.
> ...
Thank you Eike for the feedback.
Patch abandoned, initial one reverted, there's just cherry-pick for 7.0 waiting by here:
https://gerrit.libreoffice.org/c/core/+/100210

Sorry for the noise.
Comment 29 Commit Notification 2020-08-05 22:43:19 UTC
Julien Nabet committed a patch related to this issue.
It has been pushed to "libreoffice-7-0":

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

Revert "tdf#130863: autoredact, disable useless checkboxes for regex"

It will be available in 7.0.1.

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 30 guser 2020-09-11 06:36:07 UTC
In version: 7.0.1.2 is all as in 6.4. Case sensitive does not work.