mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-19 13:22:42 +01:00
Revert "Remove UTF-8 kludges from Differential"
This shouldn't have landed.
This reverts commit fe04d8bf70
.
This commit is contained in:
parent
4bfbd209b2
commit
3fc817d088
1 changed files with 20 additions and 0 deletions
|
@ -520,6 +520,9 @@ class DifferentialChangesetParser {
|
|||
ipull($this->intra, 1),
|
||||
$new_corpus);
|
||||
|
||||
$this->tokenHighlight($this->oldRender);
|
||||
$this->tokenHighlight($this->newRender);
|
||||
|
||||
$generated = (strpos($new_corpus_block, '@'.'generated') !== false);
|
||||
|
||||
$this->specialAttributes[self::ATTR_GENERATED] = $generated;
|
||||
|
@ -707,6 +710,23 @@ class DifferentialChangesetParser {
|
|||
return implode('', $result);
|
||||
}
|
||||
|
||||
|
||||
protected function tokenHighlight(&$render) {
|
||||
// TODO: This is really terribly horrible and should be fixed. We have two
|
||||
// byte-oriented algorithms (wordwrap and intraline diff) which are not
|
||||
// unicode-aware and can accept a valid UTF-8 string but emit an invalid
|
||||
// one by adding markup inside the byte sequences of characters. The right
|
||||
// fix here is to make them UTF-8 aware. Short of that, we can repair the
|
||||
// possibly-broken UTF-8 string into a valid UTF-8 string by replacing all
|
||||
// UTF-8 bytes with a Unicode Replacement Character.
|
||||
foreach ($render as $key => $text) {
|
||||
$render[$key] = preg_replace(
|
||||
'/[\x80-\xFF]/',
|
||||
'<span class="uu">'."\xEF\xBF\xBD".'</span>',
|
||||
$text);
|
||||
}
|
||||
}
|
||||
|
||||
protected function getHighlightFuture($corpus) {
|
||||
return $this->highlightEngine->getHighlightFuture(
|
||||
$this->filetype,
|
||||
|
|
Loading…
Reference in a new issue