20 use TYPO3\TestingFramework\Fluid\Unit\ViewHelpers\ViewHelperBaseTestcase;
21 use TYPO3Fluid\Fluid\Core\ViewHelper\TagBuilder;
38 protected function setUp()
42 $GLOBALS[
'TSFE']->cObj = $this->createMock(\
TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::class);
43 $this->viewHelper = $this->getMockBuilder($this->buildAccessibleProxy(\
TYPO3\CMS\Fluid\ViewHelpers\Link\EmailViewHelper::class))
44 ->setMethods([
'renderChildren'])
46 $this->injectDependenciesIntoViewHelper($this->viewHelper);
54 $mockTagBuilder = $this->getMockBuilder(TagBuilder::class)
55 ->setMethods([
'setTagName',
'addAttribute',
'setContent'])
57 $mockTagBuilder->expects($this->atLeastOnce())->method(
'setTagName')->with(
'a');
58 $mockTagBuilder->expects($this->once())->method(
'addAttribute')->with(
'href',
'mailto:some@email.tld');
59 $mockTagBuilder->expects($this->once())->method(
'setContent')->with(
'some content');
60 $this->viewHelper->setTagBuilder($mockTagBuilder);
61 $this->viewHelper->expects($this->any())->method(
'renderChildren')->will($this->returnValue(
'some content'));
62 $this->setArgumentsUnderTest(
65 'email' =>
'some@email.tld',
68 $this->viewHelper->initializeArgumentsAndRender();
76 $mockTagBuilder = $this->getMockBuilder(TagBuilder::class)
77 ->setMethods([
'setTagName',
'addAttribute',
'setContent'])
79 $mockTagBuilder->expects($this->once())->method(
'setContent')->with(
'some@email.tld');
80 $this->viewHelper->setTagBuilder($mockTagBuilder);
81 $this->viewHelper->expects($this->any())->method(
'renderChildren')->will($this->returnValue(
null));
82 $this->setArgumentsUnderTest(
85 'email' =>
'some@email.tld',
88 $this->viewHelper->initializeArgumentsAndRender();
100 '<a href="mailto:some@email.tld">some@email.tld</a>',
102 'Plain email with spam protection' => [
105 '<a href="javascript:linkTo_UnCryptMailto(%27nbjmup%2BtpnfAfnbjm%5C%2Fume%27);">some(at)email.tld</a>',
107 'Plain email with ascii spam protection' => [
110 '<a href="mailto:some@email.tld">some(at)email.tld</a>',
112 'Susceptible email' => [
113 '"><script>alert(\'email\')</script>',
115 '<a href="mailto:"><script>alert(\'email\')</script>">"><script>alert(\'email\')</script></a>',
117 'Susceptible email with spam protection' => [
118 '"><script>alert(\'email\')</script>',
120 '<a href="javascript:linkTo_UnCryptMailto(%27nbjmup%2B%5Cu0022%5Cu003E%5Cu003Ctdsjqu%5Cu003Ebmfsu%28%5Cu0027fnbjm%5Cu0027%29%5Cu003C0tdsjqu%5Cu003E%27);">"><script>alert(\'email\')</script></a>',
122 'Susceptible email with ascii spam protection' => [
123 '"><script>alert(\'email\')</script>',
125 '<a href="mailto:"><script>alert('email')</script>">"><script>alert(\'email\')</script></a>',
140 $tsfe = $this->getMockBuilder(TypoScriptFrontendController::class)
141 ->setMethods([
'dummy'])
142 ->disableOriginalConstructor()
144 $tsfe->cObj =
new ContentObjectRenderer();
145 $tsfe->spamProtectEmailAddresses = $spamProtectEmailAddresses;
148 'spamProtectEmailAddresses_atSubst' =>
'',
149 'spamProtectEmailAddresses_lastDotSubst' =>
'',
153 $viewHelper = $this->getMockBuilder(EmailViewHelper::class)
154 ->setMethods([
'isFrontendAvailable',
'renderChildren'])
156 $viewHelper->expects($this->once())->method(
'isFrontendAvailable')->willReturn(
true);
157 $viewHelper->expects($this->once())->method(
'renderChildren')->willReturn(
null);