Fix image url on alias host (#5993)

* Fix image url on alias host

* Fix image url on alias host

* Fix tests

* Updated CHANGELOG [skip ci]

Co-authored-by: Lucas Bartholemy <luke-@users.noreply.github.com>
This commit is contained in:
Yuriy Bakhtin 2022-12-28 17:16:53 +04:00 committed by GitHub
parent ac20a6fcb7
commit e41aa801b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 133 additions and 101 deletions

View File

@ -5,6 +5,7 @@ HumHub Changelog
1.13.1 (Unreleased) 1.13.1 (Unreleased)
-------------------------- --------------------------
- Fix #5985: Space user search in picker - Fix #5985: Space user search in picker
- Fix #5993: Broken images on installations with multiple URLs
1.13.0 (December 21, 2022) 1.13.0 (December 21, 2022)
-------------------------- --------------------------

View File

@ -9,7 +9,6 @@
namespace humhub\components; namespace humhub\components;
use humhub\modules\content\components\ContentContainerActiveRecord; use humhub\modules\content\components\ContentContainerActiveRecord;
use Yii;
/** /**
* UrlManager * UrlManager
@ -44,20 +43,4 @@ class UrlManager extends \yii\web\UrlManager
return parent::createUrl($params); return parent::createUrl($params);
} }
/**
* @inheritdoc
*/
public function getHostInfo()
{
$baseUrl = Yii::$app->settings->get('baseUrl');
if (empty($baseUrl)) {
return parent::getHostInfo();
}
$data = parse_url($baseUrl);
return $data['scheme'] . '://' . $data['host'] . (isset($data['port']) ? ':' . $data['port'] : '');
}
} }

View File

@ -0,0 +1,48 @@
<?php
/**
* @link https://www.humhub.org/
* @copyright Copyright (c) 2022 HumHub GmbH & Co. KG
* @license https://www.humhub.com/licences
*/
namespace humhub\libs;
use Yii;
use yii\helpers\BaseUrl;
/**
* SafeBaseUrl Helper to use host from general setting "Base URL"
*
* @since 1.13
* @author Luke
*/
class SafeBaseUrl extends BaseUrl
{
/**
* @inheritdoc
*/
protected static function getUrlManager()
{
$urlManager = clone parent::getUrlManager();
$urlManager->setHostInfo(static::getHostInfoFromSetting());
return $urlManager;
}
/**
* Get host info from general setting "Base URL"
*
* @return string|null
*/
public static function getHostInfoFromSetting(): ?string
{
$baseUrl = Yii::$app->settings->get('baseUrl');
if (empty($baseUrl)) {
return null;
}
$data = parse_url($baseUrl);
return $data['scheme'] . '://' . $data['host'] . (isset($data['port']) ? ':' . $data['port'] : '');
}
}

View File

@ -43,7 +43,7 @@ class RichTextEmailHtmlConverterTest extends HumHubDbTestCase
$this->assertConversionResult( $this->assertConversionResult(
'Test![' . $file->file_name . '](file-guid:' . $file->guid . ' "' . $file->file_name . '")Test', 'Test![' . $file->file_name . '](file-guid:' . $file->guid . ' "' . $file->file_name . '")Test',
'<p>Test<img src="http://localhost:8080/index-test.php?r=file%2Ffile%2Fdownload&amp;guid=' . $file->guid . '&amp;hash_sha1=&amp;token=' . $token . '" alt="test_image.jpg">Test</p>', [ '<p>Test<img src="http://localhost/index-test.php?r=file%2Ffile%2Fdownload&amp;guid=' . $file->guid . '&amp;hash_sha1=&amp;token=' . $token . '" alt="test_image.jpg">Test</p>', [
RichTextToEmailHtmlConverter::OPTION_RECEIVER_USER => $admin, RichTextToEmailHtmlConverter::OPTION_RECEIVER_USER => $admin,
]); ]);
} }

View File

@ -86,7 +86,7 @@ class RichTextHtmlConverterTest extends HumHubDbTestCase
{ {
$this->assertConversionResult( $this->assertConversionResult(
'Test [Link](/p/site)', 'Test [Link](/p/site)',
'<p>Test <a href="http://localhost:8080/p/site" target="_blank" rel="nofollow noreferrer noopener">Link</a></p>'); '<p>Test <a href="http://localhost/p/site" target="_blank" rel="nofollow noreferrer noopener">Link</a></p>');
} }
/** /**
@ -96,7 +96,7 @@ class RichTextHtmlConverterTest extends HumHubDbTestCase
{ {
$this->assertConversionResult( $this->assertConversionResult(
'Test [Link &< Link](/p/site)', 'Test [Link &< Link](/p/site)',
'<p>Test <a href="http://localhost:8080/p/site" target="_blank" rel="nofollow noreferrer noopener">Link &amp;&lt; Link</a></p>'); '<p>Test <a href="http://localhost/p/site" target="_blank" rel="nofollow noreferrer noopener">Link &amp;&lt; Link</a></p>');
} }
/** /**
@ -106,7 +106,7 @@ class RichTextHtmlConverterTest extends HumHubDbTestCase
{ {
$this->assertConversionResult( $this->assertConversionResult(
'Test [](/p/site)', 'Test [](/p/site)',
'<p>Test <a href="http://localhost:8080/p/site" target="_blank" rel="nofollow noreferrer noopener"></a></p>'); '<p>Test <a href="http://localhost/p/site" target="_blank" rel="nofollow noreferrer noopener"></a></p>');
} }
/** /**
@ -115,8 +115,8 @@ class RichTextHtmlConverterTest extends HumHubDbTestCase
public function testLinkWithMarkedText() public function testLinkWithMarkedText()
{ {
$this->assertConversionResult( $this->assertConversionResult(
'Test [**Bold** Link](http://localhost:8080/p/site)', 'Test [**Bold** Link](http://localhost/p/site)',
'<p>Test <a href="http://localhost:8080/p/site" target="_blank" rel="nofollow noreferrer noopener"><strong>Bold</strong> Link</a></p>'); '<p>Test <a href="http://localhost/p/site" target="_blank" rel="nofollow noreferrer noopener"><strong>Bold</strong> Link</a></p>');
} }
/** /**
@ -125,8 +125,8 @@ class RichTextHtmlConverterTest extends HumHubDbTestCase
public function testConvertLinkifiedLink() public function testConvertLinkifiedLink()
{ {
$this->assertConversionResult( $this->assertConversionResult(
'Test http://localhost:8080/p/site', 'Test http://localhost/p/site',
"<p>Test http://localhost:8080/p/site</p>"); "<p>Test http://localhost/p/site</p>");
} }
public function testConvertMailtoLink() public function testConvertMailtoLink()
@ -199,7 +199,7 @@ class RichTextHtmlConverterTest extends HumHubDbTestCase
{ {
$this->assertConversionResult( $this->assertConversionResult(
'Test ![Alt Text](/static/img/logo.png)', 'Test ![Alt Text](/static/img/logo.png)',
'<p>Test <img src="http://localhost:8080/static/img/logo.png" alt="Alt Text"></p>'); '<p>Test <img src="http://localhost/static/img/logo.png" alt="Alt Text"></p>');
} }
/** /**
@ -209,7 +209,7 @@ class RichTextHtmlConverterTest extends HumHubDbTestCase
{ {
$this->assertConversionResult( $this->assertConversionResult(
'Test ![Alt & < Text](/static/img/logo.png)', 'Test ![Alt & < Text](/static/img/logo.png)',
'<p>Test <img src="http://localhost:8080/static/img/logo.png" alt="Alt &amp; &lt; Text"></p>'); '<p>Test <img src="http://localhost/static/img/logo.png" alt="Alt &amp; &lt; Text"></p>');
} }
/** /**
@ -218,8 +218,8 @@ class RichTextHtmlConverterTest extends HumHubDbTestCase
public function testConvertImageWithTitleText() public function testConvertImageWithTitleText()
{ {
$this->assertConversionResult( $this->assertConversionResult(
'Test ![Image Alt](http://localhost:8080/static/img/logo.png "Image Title")', 'Test ![Image Alt](http://localhost/static/img/logo.png "Image Title")',
'<p>Test <img src="http://localhost:8080/static/img/logo.png" alt="Image Alt" title="Image Title"></p>'); '<p>Test <img src="http://localhost/static/img/logo.png" alt="Image Alt" title="Image Title"></p>');
} }
/** /**
@ -229,8 +229,8 @@ class RichTextHtmlConverterTest extends HumHubDbTestCase
{ {
// Image size currently not supported in html output // Image size currently not supported in html output
$this->assertConversionResult( $this->assertConversionResult(
'Test ![Scaled Image](http://localhost:8080/static/img/logo.png "img6.jpg" =150x)', 'Test ![Scaled Image](http://localhost/static/img/logo.png "img6.jpg" =150x)',
'<p>Test <img src="http://localhost:8080/static/img/logo.png" alt="Scaled Image" title="img6.jpg"></p>'); '<p>Test <img src="http://localhost/static/img/logo.png" alt="Scaled Image" title="img6.jpg"></p>');
} }
/** /**
@ -240,8 +240,8 @@ class RichTextHtmlConverterTest extends HumHubDbTestCase
{ {
// Image size currently not supported in html output // Image size currently not supported in html output
$this->assertConversionResult( $this->assertConversionResult(
'Test ![Scaled Image](http://localhost:8080/static/img/logo.png =150x)', 'Test ![Scaled Image](http://localhost/static/img/logo.png =150x)',
'<p>Test <img src="http://localhost:8080/static/img/logo.png" alt="Scaled Image"></p>'); '<p>Test <img src="http://localhost/static/img/logo.png" alt="Scaled Image"></p>');
} }
/** /**
@ -250,8 +250,8 @@ class RichTextHtmlConverterTest extends HumHubDbTestCase
public function testConvertImageWithImageAlignmentRight() public function testConvertImageWithImageAlignmentRight()
{ {
$this->assertConversionResult( $this->assertConversionResult(
'Test ![Scaled Image>](http://localhost:8080/static/img/logo.png =150x)', 'Test ![Scaled Image>](http://localhost/static/img/logo.png =150x)',
'<p>Test <img src="http://localhost:8080/static/img/logo.png" alt="Scaled Image"></p>'); '<p>Test <img src="http://localhost/static/img/logo.png" alt="Scaled Image"></p>');
} }
/** /**
@ -260,8 +260,8 @@ class RichTextHtmlConverterTest extends HumHubDbTestCase
public function testConvertImageWithImageAlignmentLeft() public function testConvertImageWithImageAlignmentLeft()
{ {
$this->assertConversionResult( $this->assertConversionResult(
'Test ![Scaled Image<](http://localhost:8080/static/img/logo.png =150x)', 'Test ![Scaled Image<](http://localhost/static/img/logo.png =150x)',
'<p>Test <img src="http://localhost:8080/static/img/logo.png" alt="Scaled Image"></p>'); '<p>Test <img src="http://localhost/static/img/logo.png" alt="Scaled Image"></p>');
} }
/** /**
@ -270,8 +270,8 @@ class RichTextHtmlConverterTest extends HumHubDbTestCase
public function testConvertImageWithImageAlignmentCenter() public function testConvertImageWithImageAlignmentCenter()
{ {
$this->assertConversionResult( $this->assertConversionResult(
'Test ![Scaled Image><](http://localhost:8080/static/img/logo.png =150x)', 'Test ![Scaled Image><](http://localhost/static/img/logo.png =150x)',
'<p>Test <img src="http://localhost:8080/static/img/logo.png" alt="Scaled Image"></p>'); '<p>Test <img src="http://localhost/static/img/logo.png" alt="Scaled Image"></p>');
} }
/* /*
@ -294,7 +294,7 @@ class RichTextHtmlConverterTest extends HumHubDbTestCase
$this->assertConversionResult( $this->assertConversionResult(
'Test mention ' . MentioningExtension::buildMentioning($user), 'Test mention ' . MentioningExtension::buildMentioning($user),
'<p>Test mention <a href="http://localhost:8080/index-test.php?r=user%2Fprofile&amp;cguid=01e50e0d-82cd-41fc-8b0c-552392f5839c" target="_blank" rel="nofollow noreferrer noopener">@Admin Tester</a></p>'); '<p>Test mention <a href="http://localhost/index-test.php?r=user%2Fprofile&amp;cguid=01e50e0d-82cd-41fc-8b0c-552392f5839c" target="_blank" rel="nofollow noreferrer noopener">@Admin Tester</a></p>');
} }
public function testMentionNotFound() public function testMentionNotFound()
@ -338,7 +338,7 @@ class RichTextHtmlConverterTest extends HumHubDbTestCase
$this->assertConversionResult( $this->assertConversionResult(
'Test file [Test File](file-guid:xyz)', 'Test file [Test File](file-guid:xyz)',
'<p>Test file <a href="http://localhost:8080/index-test.php?r=file%2Ffile%2Fdownload&amp;guid=xyz&amp;hash_sha1=xxx" target="_blank" rel="nofollow noreferrer noopener">Test File</a></p>'); '<p>Test file <a href="http://localhost/index-test.php?r=file%2Ffile%2Fdownload&amp;guid=xyz&amp;hash_sha1=xxx" target="_blank" rel="nofollow noreferrer noopener">Test File</a></p>');
} }
public function testFileNotFound() public function testFileNotFound()
@ -368,7 +368,7 @@ class RichTextHtmlConverterTest extends HumHubDbTestCase
} }
$this->assertConversionResult( $this->assertConversionResult(
'Test file ![Test File](file-guid:xyz)', 'Test file ![Test File](file-guid:xyz)',
'<p>Test file <img src="http://localhost:8080/index-test.php?r=file%2Ffile%2Fdownload&amp;guid=xyz&amp;hash_sha1=xxx" alt="Test File"></p>'); '<p>Test file <img src="http://localhost/index-test.php?r=file%2Ffile%2Fdownload&amp;guid=xyz&amp;hash_sha1=xxx" alt="Test File"></p>');
} }
public function testImageFileWithRightAlign() public function testImageFileWithRightAlign()
@ -391,7 +391,7 @@ class RichTextHtmlConverterTest extends HumHubDbTestCase
} }
$this->assertConversionResult( $this->assertConversionResult(
'Test file ![Test File>](file-guid:xyz)', 'Test file ![Test File>](file-guid:xyz)',
'<p>Test file <img src="http://localhost:8080/index-test.php?r=file%2Ffile%2Fdownload&amp;guid=xyz&amp;hash_sha1=xxx" alt="Test File"></p>'); '<p>Test file <img src="http://localhost/index-test.php?r=file%2Ffile%2Fdownload&amp;guid=xyz&amp;hash_sha1=xxx" alt="Test File"></p>');
} }
public function testDataImage() public function testDataImage()
@ -423,7 +423,7 @@ class RichTextHtmlConverterTest extends HumHubDbTestCase
} }
$this->assertConversionResult( $this->assertConversionResult(
'Test file ![Test File<](file-guid:xyz)', 'Test file ![Test File<](file-guid:xyz)',
'<p>Test file <img src="http://localhost:8080/index-test.php?r=file%2Ffile%2Fdownload&amp;guid=xyz&amp;hash_sha1=xxx" alt="Test File"></p>'); '<p>Test file <img src="http://localhost/index-test.php?r=file%2Ffile%2Fdownload&amp;guid=xyz&amp;hash_sha1=xxx" alt="Test File"></p>');
} }
public function testImageFileWithCenterAlign() public function testImageFileWithCenterAlign()
@ -446,7 +446,7 @@ class RichTextHtmlConverterTest extends HumHubDbTestCase
} }
$this->assertConversionResult( $this->assertConversionResult(
'Test file ![Test File><](file-guid:xyz)', 'Test file ![Test File><](file-guid:xyz)',
'<p>Test file <img src="http://localhost:8080/index-test.php?r=file%2Ffile%2Fdownload&amp;guid=xyz&amp;hash_sha1=xxx" alt="Test File"></p>'); '<p>Test file <img src="http://localhost/index-test.php?r=file%2Ffile%2Fdownload&amp;guid=xyz&amp;hash_sha1=xxx" alt="Test File"></p>');
} }
public function testImageFileNotFound() public function testImageFileNotFound()

View File

@ -60,7 +60,7 @@ class RichTextMarkdownConverterTest extends HumHubDbTestCase
{ {
$this->assertConversionResult( $this->assertConversionResult(
'Test [Link](/p/site)', 'Test [Link](/p/site)',
"Test [Link](http://localhost:8080/p/site)"); "Test [Link](http://localhost/p/site)");
} }
/** /**
@ -70,7 +70,7 @@ class RichTextMarkdownConverterTest extends HumHubDbTestCase
{ {
$this->assertConversionResult( $this->assertConversionResult(
'Test [Link &< Link](/p/site)', 'Test [Link &< Link](/p/site)',
"Test [Link &< Link](http://localhost:8080/p/site)"); "Test [Link &< Link](http://localhost/p/site)");
} }
/** /**
@ -80,7 +80,7 @@ class RichTextMarkdownConverterTest extends HumHubDbTestCase
{ {
$this->assertConversionResult( $this->assertConversionResult(
'Test [](/p/site)', 'Test [](/p/site)',
"Test [](http://localhost:8080/p/site)"); "Test [](http://localhost/p/site)");
} }
/** /**
@ -89,8 +89,8 @@ class RichTextMarkdownConverterTest extends HumHubDbTestCase
public function testLinkWithMarkedText() public function testLinkWithMarkedText()
{ {
$this->assertConversionResult( $this->assertConversionResult(
'Test [**Bold** Url](http://localhost:8080/p/site)', 'Test [**Bold** Url](http://localhost/p/site)',
"Test [**Bold** Url](http://localhost:8080/p/site)"); "Test [**Bold** Url](http://localhost/p/site)");
} }
/** /**
@ -99,8 +99,8 @@ class RichTextMarkdownConverterTest extends HumHubDbTestCase
public function testConvertLinkifiedLink() public function testConvertLinkifiedLink()
{ {
$this->assertConversionResult( $this->assertConversionResult(
'Test http://localhost:8080/p/site', 'Test http://localhost/p/site',
"Test http://localhost:8080/p/site"); "Test http://localhost/p/site");
} }
public function testConvertMailtoLink() public function testConvertMailtoLink()
@ -141,7 +141,7 @@ class RichTextMarkdownConverterTest extends HumHubDbTestCase
{ {
$this->assertConversionResult( $this->assertConversionResult(
'Test ![Alt Text](/static/img/logo.png)', 'Test ![Alt Text](/static/img/logo.png)',
"Test ![Alt Text](http://localhost:8080/static/img/logo.png)"); "Test ![Alt Text](http://localhost/static/img/logo.png)");
} }
/** /**
@ -151,7 +151,7 @@ class RichTextMarkdownConverterTest extends HumHubDbTestCase
{ {
$this->assertConversionResult( $this->assertConversionResult(
'Test ![Alt & < Text](/static/img/logo.png)', 'Test ![Alt & < Text](/static/img/logo.png)',
"Test ![Alt & < Text](http://localhost:8080/static/img/logo.png)"); "Test ![Alt & < Text](http://localhost/static/img/logo.png)");
} }
/** /**
@ -160,8 +160,8 @@ class RichTextMarkdownConverterTest extends HumHubDbTestCase
public function testConvertImageWithTitleText() public function testConvertImageWithTitleText()
{ {
$this->assertConversionResult( $this->assertConversionResult(
'Test ![Image Label](http://localhost:8080/static/img/logo.png "Image Title")', 'Test ![Image Label](http://localhost/static/img/logo.png "Image Title")',
"Test ![Image Label](http://localhost:8080/static/img/logo.png \"Image Title\")"); "Test ![Image Label](http://localhost/static/img/logo.png \"Image Title\")");
} }
/** /**
@ -170,8 +170,8 @@ class RichTextMarkdownConverterTest extends HumHubDbTestCase
public function testConvertImageWithSizeToText() public function testConvertImageWithSizeToText()
{ {
$this->assertConversionResult( $this->assertConversionResult(
'Test ![Scaled Image](http://localhost:8080/static/img/logo.png "img6.jpg" =150x)', 'Test ![Scaled Image](http://localhost/static/img/logo.png "img6.jpg" =150x)',
'Test ![Scaled Image](http://localhost:8080/static/img/logo.png "img6.jpg")'); 'Test ![Scaled Image](http://localhost/static/img/logo.png "img6.jpg")');
} }
/** /**
@ -180,8 +180,8 @@ class RichTextMarkdownConverterTest extends HumHubDbTestCase
public function testConvertImageWithSizeAndNoTitleToText() public function testConvertImageWithSizeAndNoTitleToText()
{ {
$this->assertConversionResult( $this->assertConversionResult(
'Test ![Scaled Image](http://localhost:8080/static/img/logo.png =150x)', 'Test ![Scaled Image](http://localhost/static/img/logo.png =150x)',
"Test ![Scaled Image](http://localhost:8080/static/img/logo.png)"); "Test ![Scaled Image](http://localhost/static/img/logo.png)");
} }
/** /**
@ -190,8 +190,8 @@ class RichTextMarkdownConverterTest extends HumHubDbTestCase
public function testConvertImageWithImageAlignmentRight() public function testConvertImageWithImageAlignmentRight()
{ {
$this->assertConversionResult( $this->assertConversionResult(
'Test ![Scaled Image>](http://localhost:8080/static/img/logo.png =150x)', 'Test ![Scaled Image>](http://localhost/static/img/logo.png =150x)',
"Test ![Scaled Image](http://localhost:8080/static/img/logo.png)"); "Test ![Scaled Image](http://localhost/static/img/logo.png)");
} }
/** /**
@ -200,8 +200,8 @@ class RichTextMarkdownConverterTest extends HumHubDbTestCase
public function testConvertImageWithImageAlignmentLeft() public function testConvertImageWithImageAlignmentLeft()
{ {
$this->assertConversionResult( $this->assertConversionResult(
'Test ![Scaled Image<](http://localhost:8080/static/img/logo.png =150x)', 'Test ![Scaled Image<](http://localhost/static/img/logo.png =150x)',
"Test ![Scaled Image](http://localhost:8080/static/img/logo.png)"); "Test ![Scaled Image](http://localhost/static/img/logo.png)");
} }
/** /**
@ -210,8 +210,8 @@ class RichTextMarkdownConverterTest extends HumHubDbTestCase
public function testConvertImageWithImageAlignmentCenter() public function testConvertImageWithImageAlignmentCenter()
{ {
$this->assertConversionResult( $this->assertConversionResult(
'Test ![Scaled Image><](http://localhost:8080/static/img/logo.png =150x)', 'Test ![Scaled Image><](http://localhost/static/img/logo.png =150x)',
"Test ![Scaled Image](http://localhost:8080/static/img/logo.png)"); "Test ![Scaled Image](http://localhost/static/img/logo.png)");
} }
/* /*

View File

@ -50,7 +50,7 @@ class RichTextPlaintextConverterTest extends HumHubDbTestCase
{ {
$this->assertConversionResult( $this->assertConversionResult(
'Test [Link](/p/site)', 'Test [Link](/p/site)',
"Test Link(http://localhost:8080/p/site)"); "Test Link(http://localhost/p/site)");
} }
/** /**
@ -60,7 +60,7 @@ class RichTextPlaintextConverterTest extends HumHubDbTestCase
{ {
$this->assertConversionResult( $this->assertConversionResult(
'Test [Link &< Link](/p/site)', 'Test [Link &< Link](/p/site)',
"Test Link &< Link(http://localhost:8080/p/site)"); "Test Link &< Link(http://localhost/p/site)");
} }
/** /**
@ -70,7 +70,7 @@ class RichTextPlaintextConverterTest extends HumHubDbTestCase
{ {
$this->assertConversionResult( $this->assertConversionResult(
'Test [](/p/site)', 'Test [](/p/site)',
"Test (http://localhost:8080/p/site)"); "Test (http://localhost/p/site)");
} }
/** /**
@ -89,8 +89,8 @@ class RichTextPlaintextConverterTest extends HumHubDbTestCase
public function testLinkWithMarkedText() public function testLinkWithMarkedText()
{ {
$this->assertConversionResult( $this->assertConversionResult(
'Test [**Bold** Url](http://localhost:8080/p/site)', 'Test [**Bold** Url](http://localhost/p/site)',
"Test Bold Url(http://localhost:8080/p/site)"); "Test Bold Url(http://localhost/p/site)");
} }
/** /**
@ -99,8 +99,8 @@ class RichTextPlaintextConverterTest extends HumHubDbTestCase
public function testConvertLinkifiedLink() public function testConvertLinkifiedLink()
{ {
$this->assertConversionResult( $this->assertConversionResult(
'Test http://localhost:8080/p/site', 'Test http://localhost/p/site',
"Test http://localhost:8080/p/site"); "Test http://localhost/p/site");
} }
public function testConvertMailtoLink() public function testConvertMailtoLink()
@ -141,7 +141,7 @@ class RichTextPlaintextConverterTest extends HumHubDbTestCase
{ {
$this->assertConversionResult( $this->assertConversionResult(
'Test ![Alt Text](/static/img/logo.png)', 'Test ![Alt Text](/static/img/logo.png)',
"Test Alt Text(http://localhost:8080/static/img/logo.png)"); "Test Alt Text(http://localhost/static/img/logo.png)");
} }
/** /**
@ -151,7 +151,7 @@ class RichTextPlaintextConverterTest extends HumHubDbTestCase
{ {
$this->assertConversionResult( $this->assertConversionResult(
'Test ![Alt & < Text](/static/img/logo.png)', 'Test ![Alt & < Text](/static/img/logo.png)',
"Test Alt & < Text(http://localhost:8080/static/img/logo.png)"); "Test Alt & < Text(http://localhost/static/img/logo.png)");
} }
/** /**
@ -160,8 +160,8 @@ class RichTextPlaintextConverterTest extends HumHubDbTestCase
public function testConvertImageWithTitleText() public function testConvertImageWithTitleText()
{ {
$this->assertConversionResult( $this->assertConversionResult(
'Test ![Image Label](http://localhost:8080/static/img/logo.png "Image Title")', 'Test ![Image Label](http://localhost/static/img/logo.png "Image Title")',
"Test Image Label(http://localhost:8080/static/img/logo.png)"); "Test Image Label(http://localhost/static/img/logo.png)");
} }
/** /**
@ -170,8 +170,8 @@ class RichTextPlaintextConverterTest extends HumHubDbTestCase
public function testConvertImageWithSizeToText() public function testConvertImageWithSizeToText()
{ {
$this->assertConversionResult( $this->assertConversionResult(
'Test ![Scaled Image](http://localhost:8080/static/img/logo.png "img6.jpg" =150x)', 'Test ![Scaled Image](http://localhost/static/img/logo.png "img6.jpg" =150x)',
"Test Scaled Image(http://localhost:8080/static/img/logo.png)"); "Test Scaled Image(http://localhost/static/img/logo.png)");
} }
/** /**
@ -180,8 +180,8 @@ class RichTextPlaintextConverterTest extends HumHubDbTestCase
public function testConvertImageWithSizeAndNoTitleToText() public function testConvertImageWithSizeAndNoTitleToText()
{ {
$this->assertConversionResult( $this->assertConversionResult(
'Test ![Scaled Image](http://localhost:8080/static/img/logo.png =150x)', 'Test ![Scaled Image](http://localhost/static/img/logo.png =150x)',
"Test Scaled Image(http://localhost:8080/static/img/logo.png)"); "Test Scaled Image(http://localhost/static/img/logo.png)");
} }
/** /**
@ -190,8 +190,8 @@ class RichTextPlaintextConverterTest extends HumHubDbTestCase
public function testConvertImageWithImageAlignmentRight() public function testConvertImageWithImageAlignmentRight()
{ {
$this->assertConversionResult( $this->assertConversionResult(
'Test ![Scaled Image>](http://localhost:8080/static/img/logo.png =150x)', 'Test ![Scaled Image>](http://localhost/static/img/logo.png =150x)',
"Test Scaled Image(http://localhost:8080/static/img/logo.png)"); "Test Scaled Image(http://localhost/static/img/logo.png)");
} }
/** /**
@ -200,8 +200,8 @@ class RichTextPlaintextConverterTest extends HumHubDbTestCase
public function testConvertImageWithImageAlignmentLeft() public function testConvertImageWithImageAlignmentLeft()
{ {
$this->assertConversionResult( $this->assertConversionResult(
'Test ![Scaled Image<](http://localhost:8080/static/img/logo.png =150x)', 'Test ![Scaled Image<](http://localhost/static/img/logo.png =150x)',
"Test Scaled Image(http://localhost:8080/static/img/logo.png)"); "Test Scaled Image(http://localhost/static/img/logo.png)");
} }
/** /**
@ -210,8 +210,8 @@ class RichTextPlaintextConverterTest extends HumHubDbTestCase
public function testConvertImageWithImageAlignmentCenter() public function testConvertImageWithImageAlignmentCenter()
{ {
$this->assertConversionResult( $this->assertConversionResult(
'Test ![Scaled Image><](http://localhost:8080/static/img/logo.png =150x)', 'Test ![Scaled Image><](http://localhost/static/img/logo.png =150x)',
"Test Scaled Image(http://localhost:8080/static/img/logo.png)"); "Test Scaled Image(http://localhost/static/img/logo.png)");
} }
/* /*

View File

@ -119,7 +119,7 @@ class RichTextShortTextConverterTest extends HumHubDbTestCase
public function testLinkWithMarkedText() public function testLinkWithMarkedText()
{ {
$this->assertConversionResult( $this->assertConversionResult(
'Test [**Bold** Url](http://localhost:8080/p/site)', 'Test [**Bold** Url](http://localhost/p/site)',
"Test Bold Url"); "Test Bold Url");
} }
@ -129,8 +129,8 @@ class RichTextShortTextConverterTest extends HumHubDbTestCase
public function testConvertLinkifiedLink() public function testConvertLinkifiedLink()
{ {
$this->assertConversionResult( $this->assertConversionResult(
'Test http://localhost:8080/p/site', 'Test http://localhost/p/site',
"Test http://localhost:8080/p/site"); "Test http://localhost/p/site");
} }
public function testConvertMailtoLink() public function testConvertMailtoLink()
@ -197,7 +197,7 @@ class RichTextShortTextConverterTest extends HumHubDbTestCase
public function testConvertImageWithTitleText() public function testConvertImageWithTitleText()
{ {
$this->assertConversionResult( $this->assertConversionResult(
'Test ![Image Label](http://localhost:8080/static/img/logo.png "Image Title")', 'Test ![Image Label](http://localhost/static/img/logo.png "Image Title")',
'Test [Image]'); 'Test [Image]');
} }
@ -207,7 +207,7 @@ class RichTextShortTextConverterTest extends HumHubDbTestCase
public function testConvertImageWithSizeToShortText() public function testConvertImageWithSizeToShortText()
{ {
$this->assertConversionResult( $this->assertConversionResult(
'Test ![Scaled Image](http://localhost:8080/static/img/logo.png "img6.jpg" =150x)', 'Test ![Scaled Image](http://localhost/static/img/logo.png "img6.jpg" =150x)',
'Test [Image]'); 'Test [Image]');
} }
@ -217,7 +217,7 @@ class RichTextShortTextConverterTest extends HumHubDbTestCase
public function testConvertImageWithSizeAndNoTitleToShortText() public function testConvertImageWithSizeAndNoTitleToShortText()
{ {
$this->assertConversionResult( $this->assertConversionResult(
'Test ![Scaled Image](http://localhost:8080/static/img/logo.png =150x)', 'Test ![Scaled Image](http://localhost/static/img/logo.png =150x)',
'Test [Image]'); 'Test [Image]');
} }
@ -227,7 +227,7 @@ class RichTextShortTextConverterTest extends HumHubDbTestCase
public function testConvertImageWithImageAlignmentRight() public function testConvertImageWithImageAlignmentRight()
{ {
$this->assertConversionResult( $this->assertConversionResult(
'Test ![Scaled Image>](http://localhost:8080/static/img/logo.png =150x)', 'Test ![Scaled Image>](http://localhost/static/img/logo.png =150x)',
'Test [Image]'); 'Test [Image]');
} }
@ -237,7 +237,7 @@ class RichTextShortTextConverterTest extends HumHubDbTestCase
public function testConvertImageWithImageAlignmentLeft() public function testConvertImageWithImageAlignmentLeft()
{ {
$this->assertConversionResult( $this->assertConversionResult(
'Test ![Scaled Image<](http://localhost:8080/static/img/logo.png =150x)', 'Test ![Scaled Image<](http://localhost/static/img/logo.png =150x)',
'Test [Image]'); 'Test [Image]');
} }
@ -247,7 +247,7 @@ class RichTextShortTextConverterTest extends HumHubDbTestCase
public function testConvertImageWithImageAlignmentCenter() public function testConvertImageWithImageAlignmentCenter()
{ {
$this->assertConversionResult( $this->assertConversionResult(
'Test ![Scaled Image><](http://localhost:8080/static/img/logo.png =150x)', 'Test ![Scaled Image><](http://localhost/static/img/logo.png =150x)',
'Test [Image]'); 'Test [Image]');
} }

View File

@ -2,11 +2,11 @@
namespace humhub\modules\user\models\forms; namespace humhub\modules\user\models\forms;
use humhub\libs\SafeBaseUrl;
use humhub\modules\user\models\User; use humhub\modules\user\models\User;
use humhub\modules\user\authclient\Password; use humhub\modules\user\authclient\Password;
use humhub\libs\UUID; use humhub\libs\UUID;
use Yii; use Yii;
use yii\helpers\Url;
use yii\base\Model; use yii\base\Model;
/** /**
@ -85,7 +85,7 @@ class AccountRecoverPassword extends Model
'text' => '@humhub/modules/user/views/mails/plaintext/RecoverPassword' 'text' => '@humhub/modules/user/views/mails/plaintext/RecoverPassword'
], [ ], [
'user' => $user, 'user' => $user,
'linkPasswordReset' => Url::to(['/user/password-recovery/reset', 'token' => $token, 'guid' => $user->guid], true) 'linkPasswordReset' => SafeBaseUrl::to(['/user/password-recovery/reset', 'token' => $token, 'guid' => $user->guid], true)
]); ]);
$mail->setTo($user->email); $mail->setTo($user->email);
$mail->setSubject(Yii::t('UserModule.account', 'Password Recovery')); $mail->setSubject(Yii::t('UserModule.account', 'Password Recovery'));

View File

@ -28,7 +28,7 @@ class ApproveUserFormTest extends HumHubDbTestCase
$form = new ApproveUserForm($this->unapprovedUser->id); $form = new ApproveUserForm($this->unapprovedUser->id);
$form->setApprovalDefaults(); $form->setApprovalDefaults();
$this->assertEquals("Hello UnApproved User,\n\nYour account has been activated.\n\n" . $this->assertEquals("Hello UnApproved User,\n\nYour account has been activated.\n\n" .
"Click here to login:\nhttp://localhost:8080/index-test.php?r=user%2Fauth%2Flogin\n\n" . "Click here to login:\nhttp://localhost/index-test.php?r=user%2Fauth%2Flogin\n\n" .
"Kind Regards\nAdmin Tester\n\n", $form->message); "Kind Regards\nAdmin Tester\n\n", $form->message);
$settings = new AuthenticationSettingsForm(); $settings = new AuthenticationSettingsForm();
@ -68,7 +68,7 @@ Mit freundlichen Grüßen
$form = new ApproveUserForm($this->unapprovedUser->id); $form = new ApproveUserForm($this->unapprovedUser->id);
$form->setApprovalDefaults(); $form->setApprovalDefaults();
$this->assertEquals("Hey UnApproved User your account was approved by Admin Tester, please click <a href=\"http://localhost:8080/index-test.php?r=user%2Fauth%2Flogin\">http://localhost:8080/index-test.php?r=user/auth/login</a>" $this->assertEquals("Hey UnApproved User your account was approved by Admin Tester, please click <a href=\"http://localhost/index-test.php?r=user%2Fauth%2Flogin\">http://localhost/index-test.php?r=user/auth/login</a>"
, $form->message); , $form->message);
} }
@ -86,7 +86,7 @@ Mit freundlichen Grüßen
Dein Konto wurde aktiviert. Dein Konto wurde aktiviert.
Klicke hier um dich einzuloggen: Klicke hier um dich einzuloggen:
http://localhost:8080/index-test.php?r=user%2Fauth%2Flogin http://localhost/index-test.php?r=user%2Fauth%2Flogin
Mit freundlichen Grüßen Mit freundlichen Grüßen
Admin Tester", $form->message); Admin Tester", $form->message);