Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit a9c56f6

Browse filesBrowse files
committed
Fix Links in blade views are misplaced after multibyte characters
Fixes N1ebieski#9
1 parent 44e2937 commit a9c56f6
Copy full SHA for a9c56f6

File tree

1 file changed

+5
-10
lines changed
Filter options

1 file changed

+5
-10
lines changed

‎app/Parsers/InlineHtmlParser.php

Copy file name to clipboardExpand all lines: app/Parsers/InlineHtmlParser.php
+5-10Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,19 +35,14 @@ class InlineHtmlParser extends AbstractParser
3535
protected array $items = [];
3636

3737
/**
38-
* There is a bug with the Stillat\BladeParser\Document\Document::fromText parser.
39-
* It doesn't parse the special characters correctly. It treats these characters
38+
* Stillat\BladeParser\Document\Document::fromText treats multibyte characters
4039
* as indentations and spaces resulting in a miscalculated Node position.
4140
*
42-
* This function replaces the special characters with a single, placeholder character
41+
* This function replaces the multibyte characters with a single, placeholder character
4342
*/
44-
private function replaceSpecialAndEmoji(string $text, string $placeholder = '*'): string
43+
private function replaceMultibyteChars(string $text, string $placeholder = '*'): string
4544
{
46-
return preg_replace(
47-
'/[\x{3040}-\x{30FF}\x{4E00}-\x{9FFF}\x{1F300}-\x{1FAFF}\x{1F000}-\x{1F6FF}\x{2190}-\x{21AA}\x{2300}-\x{23FF}\x{25A0}-\x{25FF}\x{1F600}-\x{1F64F}\x{1F680}-\x{1F6FF}\x{2700}-\x{27BF}]/u',
48-
$placeholder,
49-
$text
50-
);
45+
return preg_replace('/[^\x00-\x7F]/u', $placeholder, $text);
5146
}
5247

5348
public function parse(InlineHtml $node)
@@ -63,7 +58,7 @@ public function parse(InlineHtml $node)
6358
}
6459

6560
$this->parseBladeContent(Document::fromText(
66-
$this->replaceSpecialAndEmoji($node->getText())
61+
$this->replaceMultibyteChars($node->getText())
6762
));
6863

6964
if (count($this->items)) {

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.