Skip to content

Commit 7e45ee4

Browse files
Fix title length check and improve analyzer-include-spacekey config
1 parent b26fa4f commit 7e45ee4

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

src/Analyzer/ConfluenceAnalyzer.php

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,15 @@ private function setConfigVars(): void {
155155
if ( isset( $this->advancedConfig['mainpage'] ) ) {
156156
$this->mainpage = $this->advancedConfig['mainpage'];
157157
}
158+
159+
if ( isset( $this->advancedConfig['analyzer-include-spacekey'] ) ) {
160+
$analyzerIncludeSpacekey = $this->advancedConfig['analyzer-include-spacekey'];
161+
$normalizedAnalyzerIncludeSpacekey = [];
162+
foreach ( $analyzerIncludeSpacekey as $key ) {
163+
$normalizedAnalyzerIncludeSpacekey[] = strtolower( $key );
164+
}
165+
$this->advancedConfig['analyzer-include-spacekey'] = $normalizedAnalyzerIncludeSpacekey;
166+
}
158167
}
159168

160169
/**
@@ -639,8 +648,8 @@ private function buildPageMaps( DOMDocument $dom ): void {
639648
}
640649
$prefix = $spaceIdToPrefixMap[$spaceId];
641650
if (
642-
isset( $this->config['analyzer-include-spacekey'] )
643-
&& !in_array( $prefix, $this->config['analyzer-include-spacekey'] )
651+
isset( $this->advancedConfig['analyzer-include-spacekey'] )
652+
&& !in_array( strtolower( $prefix ), $this->advancedConfig['analyzer-include-spacekey'] )
644653
) {
645654
return;
646655
}
@@ -1106,7 +1115,7 @@ private function checkTitles(): void {
11061115
$hasInvalidNamespaces = true;
11071116
}
11081117

1109-
if ( mb_strlen( $text ) > 255 ) {
1118+
if ( mb_strlen( urlencode( $text ) ) > 255 ) {
11101119
$this->customBuckets->addData(
11111120
'invalid-titles',
11121121
'length', $title,
@@ -1115,7 +1124,7 @@ private function checkTitles(): void {
11151124
$hasInvalidTitles = true;
11161125
}
11171126
} else {
1118-
if ( mb_strlen( $title ) > 255 ) {
1127+
if ( mb_strlen( urlencode( $title ) ) > 255 ) {
11191128
$this->customBuckets->addData(
11201129
'invalid-titles',
11211130
'length', $title,

0 commit comments

Comments
 (0)