Bug 264343 - mail/squirrelmail: Fix spell checker not working
Summary: mail/squirrelmail: Fix spell checker not working
Status: Open
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Some People
Assignee: freebsd-ports-bugs (Nobody)
URL:
Keywords: needs-patch, needs-qa
Depends on:
Blocks:
 
Reported: 2022-05-30 07:30 UTC by dewayne
Modified: 2022-05-31 05:32 UTC (History)
1 user (show)

See Also:
bugzilla: maintainer-feedback? (uzsolt)
koobs: merge-quarterly?


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description dewayne 2022-05-30 07:30:09 UTC
To enable aspell to function correctly, I changed the line containing SQSPELL_EREG from ereg to preg_match.
in "/usr/local/www/squirrelmail/plugins/squirrelspell/sqspell_config.php".
/* $SQSPELL_EREG = 'ereg'; */
$SQSPELL_EREG = 'preg_match';

Magically the embedded plugin for spell-checker functionality worked.  I modified another line, negating a general patch. For reference: 
$SQSPELL_APP = array('English' => '/usr/local/bin/aspell -d en_AU -a');

For uzsolt@uzsolt.hu 
sed -i '' -e "/_EREG/s/ereg/preg_match/1" "/usr/local/www/squirrelmail/plugins/squirrelspell/sqspell_config.php"
Comment 1 Kubilay Kocak freebsd_committer freebsd_triage 2022-05-30 23:30:08 UTC
(In reply to dewayne from comment #0)

Are you able to produce a patch against the port using `make makepatch` ?
Comment 2 Zsolt Udvari freebsd_committer freebsd_triage 2022-05-31 05:21:02 UTC
I think because it's a config file the user should overwrite this.
IMHO it's better to create a pkg-message which describes this method if user wants spell-checking (and I should create a sqspell_config.php.sample file as in /usr/local/etc).
What do you think?
Comment 3 Zsolt Udvari freebsd_committer freebsd_triage 2022-05-31 05:32:09 UTC
Hm, I can see the problem: the ereg is deprecated and removed from PHP7+ and should use preg_match instead.
But there are one problem (at least): these functions return values differ,
ereg: 
"Returns the length of the matched string if a match for pattern was found in string, or FALSE if no matches were found or an error occurred.

If the optional parameter regs was not passed or the length of the matched string is 0, this function returns 1."

preg_match:
"preg_match() returns 1 if the pattern matches given subject, 0 if it does not, or false on failure. "

We should check every calls of ereg and check the parameters and the handle of return value - and change it if needed.