Menu

#239 RESOURCECOMMON.php::doHighlight; preg_replace endless loop

6.3.8
closed
None
6.3.7
Bug
7.3
macOS
2020-08-11
2020-08-11
Nap
No

[MacOS Catalina 10.15.3,
Apache/2.4.43 (Unix) mod_fcgid/2.3.10-dev PHP/7.3.11 ,
MySQL (mysql Ver 14.14 Distrib 5.7.20, for macos10.12 (x86_64) using EditLine wrapper),
WikiNDX 6.3.7]

I'm not really good with BUG Reports, so any suggestions on how to improve my report are welcome.

This bug report has to do with pasting images directly into the text areas (I've been doing this with the abstract and note fields).

In PARSEPHRASE.php::createCondition, line 405, the line should be updated to:
$storedHighlight = array_filter(UTF8::mb_explode(',', $this->session->getVar("search_Highlight")));
Whereby array_filter has been added to the existing code.

This is required because if search_Hightlight is not set, $this->session->getVar("search_Highlight") returns an array with element [0] equal to an empty string.
The next line merges $storedHighlight with $searchHighlight. Because $storedHighlight has an empty string, this results in $storedHighlight being set to ",SearchTerm" which confuses further implode statements because of the leading comma.
The array_filter command (which can have a callback function defined) removes all entries/elements that evaluate to false; e.g. empty strings, null values, and boolean false values from the array.

The symptom of this problem is not noticed until you paste images into the text fields being searched. You will know when this occurs because Apache->php will go into an endless loop that requires Apache to be restarted. In order to trigger the problem outlined below, do the following:

  • Create a resource with pasted images in the Abstract or Notes fields.
  • After doing a Quick Search say on the author, choose to view the resource.
  • PHP will go into an endless loop when it gets to the preg_replace in RESOURCECOMMON.php::doHighlight, line 136.
  • (This requires the Apache server to be restarted.)

Filtering $storedHighlight as indicated above fixes this problem.

Discussion

  • Mark Grimshaw

    Mark Grimshaw - 2020-08-11
    • assigned_to: Mark Grimshaw
    • Target: 6.3.7 --> 6.3.8
     
  • Mark Grimshaw

    Mark Grimshaw - 2020-08-11

    Thanks Nap,

    I'd say that's a pretty comprehensive bug report. I'll look into it today.

    Regards,

    Mark

     
  • Mark Grimshaw

    Mark Grimshaw - 2020-08-11
    • status: open --> closed
     
  • Mark Grimshaw

    Mark Grimshaw - 2020-08-11

    Thanks Nap,

    Fixed in SVN.

    Mark

     

Log in to post a comment.