Skip to content

Commit 183fcd7

Browse files
authored
Merge pull request #1 from aternosorg/invalid-encoding
Fix fatal error that is thrown when the input string has an invalid encoding
2 parents 7d2db7d + 685610f commit 183fcd7

File tree

3 files changed

+25
-16
lines changed

3 files changed

+25
-16
lines changed

composer.json

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,37 @@
11
{
22
"name": "aternos/licensee",
33
"description": "A library to detect well-known licenses based on their title or content.",
4-
"type": "library",
54
"license": "MIT",
6-
"bin": ["bin/licensee-update-data"],
7-
"autoload": {
8-
"psr-4": {
9-
"Aternos\\Licensee\\": "src/"
10-
}
11-
},
12-
"autoload-dev": {
13-
"psr-4": {
14-
"Tests\\": "tests/"
15-
}
16-
},
5+
"type": "library",
176
"authors": [
187
{
198
"name": "Kurt Thiemann",
209
"email": "[email protected]"
2110
}
2211
],
2312
"require": {
13+
"php": ">=8.3",
2414
"ext-dom": "*",
25-
"league/html-to-markdown": "^5.1",
15+
"ext-mbstring": "*",
2616
"ext-yaml": "*",
27-
"php": ">=8.3"
17+
"league/html-to-markdown": "^5.1"
2818
},
2919
"require-dev": {
3020
"phpunit/phpunit": "^11.5"
3121
},
22+
"autoload": {
23+
"psr-4": {
24+
"Aternos\\Licensee\\": "src/"
25+
}
26+
},
27+
"autoload-dev": {
28+
"psr-4": {
29+
"Tests\\": "tests/"
30+
}
31+
},
32+
"bin": [
33+
"bin/licensee-update-data"
34+
],
3235
"scripts": {
3336
"test": "phpunit --config phpunit.xml --testdox"
3437
}

composer.lock

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/License/Text/LicenseText.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,13 @@
3333
use Aternos\Licensee\TextTransformer\StripUrlTransformer;
3434
use Aternos\Licensee\TextTransformer\StripVersionTransformer;
3535
use Aternos\Licensee\TextTransformer\StripWhitespaceTransformer;
36+
use Aternos\Licensee\TextTransformer\TextTransformer;
3637

3738
class LicenseText
3839
{
40+
/**
41+
* @var TextTransformer[]
42+
*/
3943
protected array $transformers;
4044
protected ?string $normalizedContent = null;
4145
protected ?array $wordSet = null;
@@ -101,7 +105,7 @@ public function __construct(
101105
public function getNormalizedContent(): string
102106
{
103107
if ($this->normalizedContent === null) {
104-
$this->normalizedContent = $this->content;
108+
$this->normalizedContent = mb_convert_encoding($this->content, 'utf8');
105109
foreach ($this->transformers as $transformer) {
106110
$this->normalizedContent = $transformer->transform($this->normalizedContent);
107111
$this->normalizedContent = RegExpException::handleNull(preg_replace("# +#", " ", $this->normalizedContent));

0 commit comments

Comments
 (0)