diff --git a/_test/tests/inc/parser/renderer_xhtml.test.php b/_test/tests/inc/parser/renderer_xhtml.test.php
index 295f04ee79..f7be39a1b7 100644
--- a/_test/tests/inc/parser/renderer_xhtml.test.php
+++ b/_test/tests/inc/parser/renderer_xhtml.test.php
@@ -248,4 +248,26 @@ function test_ulist() {
';
$this->assertEquals($expected, $this->R->doc);
}
+
+ public function test_blankHeader() {
+ $this->R->header('0', 1, 1);
+ $expected = '
0
';
+ $this->assertEquals($expected, trim($this->R->doc));
+ }
+
+ public function test_blankTitleLink() {
+ global $conf;
+ $id = 'blanktest';
+
+ $conf['useheading'] = 1;
+ saveWikiText($id,'====== 0 ======', 'test');
+ $this->assertTrue(page_exists($id));
+
+ $header = p_get_first_heading($id, METADATA_RENDER_UNLIMITED);
+ $this->assertSame('0', $header);
+
+ $this->R->internallink($id);
+ $expected = '0';
+ $this->assertEquals($expected, trim($this->R->doc));
+ }
}
diff --git a/inc/confutils.php b/inc/confutils.php
index 7a3a99856d..83cc4d34f3 100644
--- a/inc/confutils.php
+++ b/inc/confutils.php
@@ -309,6 +309,7 @@ function actionOK($action){
*/
function useHeading($linktype) {
static $useHeading = null;
+ if(defined('DOKU_UNITTEST')) $useHeading = null; // don't cache during unit tests
if (is_null($useHeading)) {
global $conf;
diff --git a/inc/parser/xhtml.php b/inc/parser/xhtml.php
index 51316b3bf3..e60d7d38b9 100644
--- a/inc/parser/xhtml.php
+++ b/inc/parser/xhtml.php
@@ -191,7 +191,7 @@ function toc_additem($id, $text, $level) {
function header($text, $level, $pos) {
global $conf;
- if(!$text) return; //skip empty headlines
+ if(blank($text)) return; //skip empty headlines
$hid = $this->_headerToLink($text, true);
@@ -1702,7 +1702,7 @@ function _getLinkTitle($title, $default, &$isImage, $id = null, $linktype = 'con
} elseif(is_null($title) || trim($title) == '') {
if(useHeading($linktype) && $id) {
$heading = p_get_first_heading($id);
- if($heading) {
+ if(!blank($heading)) {
return $this->_xmlEntities($heading);
}
}