[MGNLUI-3100] AdminCentral & SearchJcrContainer: Using characters ( { [ ''' crashes the AdminCentral Created: 13/Aug/14  Updated: 05/Dec/14  Resolved: 20/Aug/14

Status: Closed
Project: Magnolia UI
Component/s: workbench
Affects Version/s: 5.2.8, 5.3.2
Fix Version/s: 5.2.9, 5.3.3

Type: Bug Priority: Neutral
Reporter: Christian Ringele Assignee: Eric Hechinger
Resolution: Fixed Votes: 0
Labels: support
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
causality
Template:
Acceptance criteria:
Empty
Task DoD:
[ ]* Doc/release notes changes? Comment present?
[ ]* Downstream builds green?
[ ]* Solution information and context easily available?
[ ]* Tests
[ ]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)
Bug DoR:
[ ]* Steps to reproduce, expected, and actual results filled
[ ]* Affected version filled
Date of First Response:

 Description   

This happens only on the fist search dropped after opening an app using the SearchJcrContainer (content apps in the workbench).

Reproduce crash:

  • Open for example the contacts app
  • enter one if these search terms:
    (
    {
    [
    '''
    anythingAnd(inbetween
    

No crash when:

  • Open app
  • enter valid search term
  • removing the term using the at the right of the search field
  • drop one of the characters that don't work in first search

Errors:
The initial Error:

Aug 13, 2014 4:35:10 PM com.vaadin.server.DefaultErrorHandler doDefault
SEVERE: 
java.lang.RuntimeException: Unable to get item id for index: 0 from container using Container.Indexed#getIdByIndex() even though container.size() > endIndex. Returned item id was null. Check your container implementation!
	at com.vaadin.data.ContainerHelpers.getItemIdsUsingGetIdByIndex(ContainerHelpers.java:90)
	at info.magnolia.ui.workbench.container.AbstractJcrContainer.getItemIds(AbstractJcrContainer.java:676)
	at com.vaadin.ui.Table.getItemIds(Table.java:2219)
	at com.vaadin.ui.Table.getVisibleCellsNoCache(Table.java:2169)
	at com.vaadin.ui.Table.refreshRenderedCells(Table.java:1694)
	at com.vaadin.ui.Table.getVisibleCells(Table.java:3960)

Happens when the calls "ContainerHelpers.getItemIdsUsingGetIdByIndex(startIndex, numberOfItems, this);" which calls on the used container the method getIdByIndex(int):

info.magnolia.ui.workbench.container.AbstractJcrContainer.getIdByIndex(int)

The system complaints about illegal characters used for the full text search:

2014-08-13 16:08:05,914 WARN  gnolia.ui.workbench.container.AbstractJcrContainer: Could not update size with statement: select * from [nt:base] as t where (([jcr:primaryType] = 'mgnl:contact' or [jcr:primaryType] = 'mgnl:folder') and (lower(localname()) LIKE '(%' or t.['('] IS NOT NULL or contains(t.*, '(')) ): javax.jcr.RepositoryException: Invalid full text search expression: (
2014-08-13 16:08:19,833 WARN  gnolia.ui.workbench.container.AbstractJcrContainer: Cannot get Page with statement: select * from [nt:base] as t where (([jcr:primaryType] = 'mgnl:contact' or [jcr:primaryType] = 'mgnl:folder') and (lower(localname()) LIKE '(%' or t.['('] IS NOT NULL or contains(t.*, '(')) ) order by score(t) desc: javax.jcr.RepositoryException: Invalid full text search expression: (

Looked into:
First I suspected this method:

info.magnolia.ui.workbench.search.SearchJcrContainer.escapeIllegalFullTextSearchChars(String)

as it uses the variable

private static final String illegalFullTextChars = "-+)\"\\";

to determine the invalid characters.

Then I checked the method:
info.magnolia.ui.workbench.search.SearchJcrContainer.getQueryWhereClauseSearch()
Where the

 final String escapedSearch = Text.escapeIllegalJcrChars(unescapedFullTextExpression);

is already using the Text.escapeIllegalJcrChars to remove illegal characters.

But all this can't be the full source of the problem, because this does not explain why it only doesn't work as a first dropped search. If the excaping alone would be the problem, then it would never work.

What surprises is:
If changing in the method "info.magnolia.ui.workbench.search.SearchJcrContainer.getQueryWhereClauseSearch()"
just for testing the

final String unescapedFullTextExpression = getFullTextExpression();

by

final String unescapedFullTextExpression = "\\(";

it works perfectly.


Generated at Mon Feb 12 09:03:13 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.