Bug 1062351

Summary: [RFE] Search mechanism doesn't handle particular special characters well
Product: [oVirt] ovirt-engine Reporter: Pavel Novotny <pnovotny>
Component: RFEsAssignee: Eli Mesika <emesika>
Status: CLOSED CURRENTRELEASE QA Contact: Pavel Novotny <pnovotny>
Severity: low Docs Contact:
Priority: unspecified    
Version: ---CC: bugs, emesika, gklein, iheim, oourfali, pstehlik, rbalakri, yeylon
Target Milestone: ovirt-3.6.0-rcKeywords: FutureFeature
Target Release: 3.6.0Flags: rule-engine: ovirt-3.6.0+
ylavi: planning_ack+
rule-engine: devel_ack+
pstehlik: testing_ack+
Hardware: Unspecified   
OS: Unspecified   
Whiteboard: infra
Fixed In Version: ovirt-engine-3.6.0-0.0.master.20150412172306.git55ba764 Doc Type: Enhancement
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-02-02 10:35:52 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: Infra RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Pavel Novotny 2014-02-06 17:29:08 UTC
Description of problem:
Entities (like DCs, VMs, templates, ...) with special character in the description or comment cannot be found according to it. 

Version-Release number of selected component (if applicable):
ovirt-engine-3.4.0-0.5.beta1.el6.noarch

How reproducible:
100%

Steps to Reproduce:
1. Create a DC (or cluster, storage, VM,...) with special character(s) in the description.
   By special characters it's meant: !#^&<>;"'
2. Search the DC by description using one of the special characters in the search query, i.e.,
   Datacenter: description = "#"
   -- or with wildcards --
   Datacenter: description = "*#*"
3. 

Actual results:
The search result is empty.
In the engine.log you'll find a warn message, but no warning appears in the UI (Webadmin) - nothing in the bottom Events panel nor anywhere else. 

engine.log:
2014-02-06 17:45:01,825 WARN  [org.ovirt.engine.core.bll.SearchQuery] (ajp--127.0.0.1-8702-11) ResourceManager::searchBusinessObjects - erroneous search text - Datacenter: description = "*#*"


Expected results:
Special characters should be treated as plain strings so DC from step 1 is returned.


Additional info:
Three more characters are problematic:
1. '\' character is ignored when searching (I guess the search backend filters it out from the search query)
2. there is no way how to search the '*' character, because it's used as the wildcard character
3. '%' character is interchangeable with '*' so you cannot search for it neither

Comment 1 Martin Pavlik 2014-02-20 15:05:45 UTC
There is also no way how to search for items which do not have certain field filled at all.

For example I want to see all network which do not have a any label

Search: 
Network: label = ""
does not work

nor does 
Network: label != "*"

Comment 2 Eli Mesika 2014-02-20 21:09:53 UTC
(In reply to Martin Pavlik from comment #1)
> There is also no way how to search for items which do not have certain field
> filled at all.
> 
> For example I want to see all network which do not have a any label
> 
> Search: 
> Network: label = ""
> does not work
> 
> nor does 
> Network: label != "*"

I agree, more accurate handling IMHO will be to support special values NULL and EMPTY_STRING to enable that and this worth a special RFE that will probably enable us to handle it before this RFE since it is less complex.

So, if you have no objection, please  open a different RFE on that

Comment 3 Martin Pavlik 2014-02-21 07:26:30 UTC
Done, opened bug 1067844

Comment 4 Eli Mesika 2014-08-31 13:27:48 UTC
I had investigated it and its origin is in BaseConditionFieldAutoCompleter::isValid(String field, String value)
This method is called from various value types detection and disallow any char of : {^,<,>,&,#,!,;}

I think that this method is redundant, when we have a string value we should allow all
I had checked returning true from BaseConditionFieldAutoCompleter::isValid(String field, String value) and it worked perfectly 

Yair, do we have any problem having those characters in AD search ?

Comment 5 Yair Zaslavsky 2014-09-01 02:12:50 UTC
(In reply to Eli Mesika from comment #4)
> I had investigated it and its origin is in
> BaseConditionFieldAutoCompleter::isValid(String field, String value)
> This method is called from various value types detection and disallow any
> char of : {^,<,>,&,#,!,;}
> 
> I think that this method is redundant, when we have a string value we should
> allow all
> I had checked returning true from
> BaseConditionFieldAutoCompleter::isValid(String field, String value) and it
> worked perfectly 
> 
> Yair, do we have any problem having those characters in AD search ?

& and ! are used in the ldap query language.

You can see here a list of characters that need t boe escaped -

http://docs.oracle.com/javase/jndi/tutorial/beyond/names/syntax.html

<   >   #  ;   are among these characters.

Comment 6 Pavel Stehlik 2016-02-02 10:35:52 UTC
Closing older BZs, if still happened, please reopen.