osclass/Osclass — pull request #1414 by emanwebdev (2014-03-23 06:37:49+00:00)
Title: Fix osc_highlight() truncating HTML entities e.g. '&eacut'

For a reason i haven't sought after (TinyMCE? back-office post-processing?) osc_item_description() returns accentuated characters as HTML entities.
When an HTML entity is around the `$len` position, it got truncated, e.g. `z&eacut`
It gets then displayed as it with the hard-coded ellipsis : `z&eacut...`
( and btw invalidates the HTML code as the HTML entity is not terminated by a `;`)

This fix simply converts all HTML entities in the string to their applicable characters, truncate, and converts back all applicable characters to HTML entities

**IMPORTANT NOTE** regarding encoding and PHP compatibility:
Not sure about `ENT_NOQUOTES | ENT_XHTML` or other? tried `ENT_HTML401` and `ENT_HTML5` too, but according to the [PHP Manual function.htmlentities](http://www.php.net/manual/en/function.htmlentities.php#refsect1-function.htmlentities-changelog) all these constants are only available since PHP 5.4+.
Since i can't find any requirements specifications nor in the [README.md](https://github.com/osclass/Osclass/blob/master/README.md#installation) nor on [Get Started](http://osclass.org/page/get-started) nor on [doc.osclass.org Installing](http://doc.osclass.org/Install), not sure about the use of these constants in Osclass code.

Since the official Bender Theme is in XHTML 1.0, this fix proposal comes with the `ENT_XHTML` flag. Up to you to use `ENT_HTML5` if you use a HTML% theme or e.g. you allow images to be inserted with TinyMCE in your ads.

_Final note_: Yes, another optional parameter would solve this issue. Especially since the encoding of the document is front-end related, the encoding type should not be hard-coded here in a back-office helper. In a perfect world. ![In a perfect world](http://d3l2rivt3pqnj2.cloudfront.net/i/prints/180/2/9/293691.jpg) :yum: