Uploaded image for project: 'Magnolia UI'
  1. Magnolia UI
  2. MGNLUI-3100

AdminCentral & SearchJcrContainer: Using characters ( { [ ''' crashes the AdminCentral

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Neutral Neutral
    • 5.2.9, 5.3.3
    • 5.2.8, 5.3.2
    • workbench

      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.

        Acceptance criteria

              ehechinger Eric Hechinger
              cringele Christian Ringele
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved:

                  Bug DoR
                  Task DoD