This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | namespace Famelo\Messaging; |
||
3 | |||
4 | /* * |
||
5 | * This script belongs to the TYPO3 Flow package "Famelo.Messaging". * |
||
6 | * * |
||
7 | * It is free software; you can redistribute it and/or modify it under * |
||
8 | * the terms of the GNU Lesser General Public License, either version 3 * |
||
9 | * of the License, or (at your option) any later version. * |
||
10 | * * |
||
11 | * The TYPO3 project - inspiring people to share! * |
||
12 | * */ |
||
13 | |||
14 | use TYPO3\Flow\Annotations as Flow; |
||
15 | use TYPO3\Flow\Mvc\ActionRequest; |
||
16 | use TYPO3\Flow\Reflection\ObjectAccess; |
||
17 | |||
18 | /** |
||
19 | * Message class for the SwiftMailer package |
||
20 | * |
||
21 | * @Flow\Scope("prototype") |
||
22 | */ |
||
23 | class Message extends \TYPO3\SwiftMailer\Message { |
||
24 | /* |
||
25 | * @var string |
||
26 | */ |
||
27 | protected $templatePath = 'resource://@package/Private/Messages/@message.html'; |
||
28 | |||
29 | /* |
||
30 | * @var string |
||
31 | */ |
||
32 | protected $partialRootPath = 'resource://@package/Private/Partials'; |
||
33 | |||
34 | /** |
||
35 | * @var string |
||
36 | */ |
||
37 | protected $message = 'Standard'; |
||
38 | |||
39 | /** |
||
40 | * @var string |
||
41 | */ |
||
42 | protected $package = NULL; |
||
43 | |||
44 | /** |
||
45 | * @var string |
||
46 | */ |
||
47 | protected $source = NULL; |
||
48 | |||
49 | /** |
||
50 | * @var string |
||
51 | */ |
||
52 | protected $rawBody; |
||
53 | |||
54 | /** |
||
55 | * @Flow\Inject |
||
56 | * @var \TYPO3\Flow\Configuration\ConfigurationManager |
||
57 | */ |
||
58 | protected $configurationManager; |
||
59 | |||
60 | /** |
||
61 | * The view |
||
62 | * |
||
63 | * @var \Famelo\Messaging\View\StandaloneView |
||
64 | * @Flow\Inject |
||
65 | */ |
||
66 | protected $view; |
||
67 | |||
68 | /** |
||
69 | * @Flow\Inject |
||
70 | * @var \TYPO3\Flow\Mvc\Routing\RouterInterface |
||
71 | */ |
||
72 | protected $router; |
||
73 | |||
74 | /** |
||
75 | * @var boolean |
||
76 | */ |
||
77 | protected static $routerConfigured = FALSE; |
||
78 | |||
79 | /** |
||
80 | * @var string |
||
81 | */ |
||
82 | protected $contentType; |
||
83 | |||
84 | public function __construct($subject = NULL, $body = NULL, $contentType = NULL, $charset = NULL) { |
||
85 | if ($contentType === NULL) { |
||
86 | $contentType = 'text/html'; |
||
87 | } |
||
88 | $this->contentType = $contentType; |
||
89 | parent::__construct($subject, $body, $contentType, $charset); |
||
90 | } |
||
91 | |||
92 | public function setMessage($message) { |
||
93 | $parts = explode(':', $message); |
||
94 | if (count($parts) > 1) { |
||
95 | $this->package = $parts[0]; |
||
96 | $this->message = $parts[1]; |
||
97 | $this->view->getRequest()->setControllerPackageKey($this->package); |
||
98 | } else { |
||
99 | $this->message = $message; |
||
100 | } |
||
101 | return $this; |
||
102 | } |
||
103 | |||
104 | public function send() { |
||
105 | $this->prepare(); |
||
106 | parent::send(); |
||
107 | } |
||
108 | |||
109 | public function prepare() { |
||
110 | $defaultFrom = $this->configurationManager->getConfiguration(\TYPO3\Flow\Configuration\ConfigurationManager::CONFIGURATION_TYPE_SETTINGS, 'Famelo.Messaging.defaultFrom'); |
||
111 | if ($defaultFrom !== NULL && $this->getFrom() === array()) { |
||
112 | $this->setFrom($defaultFrom); |
||
113 | } |
||
114 | |||
115 | $this->initializeRouter(); |
||
116 | $this->setBody($this->render(), $this->contentType); |
||
117 | $this->setOptionsByViewHelper(); |
||
118 | |||
119 | $redirectAllMessagesTo = $this->configurationManager->getConfiguration(\TYPO3\Flow\Configuration\ConfigurationManager::CONFIGURATION_TYPE_SETTINGS, 'Famelo.Messaging.redirectAllMessagesTo'); |
||
120 | if ($redirectAllMessagesTo !== NULL) { |
||
121 | $this->setTo($redirectAllMessagesTo); |
||
122 | } |
||
123 | } |
||
124 | |||
125 | public function initializeRouter() { |
||
126 | if (FLOW_SAPITYPE === 'CLI' && self::$routerConfigured === FALSE) { |
||
127 | $routesConfiguration = $this->configurationManager->getConfiguration(\TYPO3\Flow\Configuration\ConfigurationManager::CONFIGURATION_TYPE_ROUTES); |
||
128 | $this->router->setRoutesConfiguration($routesConfiguration); |
||
129 | self::$routerConfigured = TRUE; |
||
130 | putenv('REDIRECT_FLOW_REWRITEURLS=true'); |
||
131 | } |
||
132 | $baseUri = $this->configurationManager->getConfiguration(\TYPO3\Flow\Configuration\ConfigurationManager::CONFIGURATION_TYPE_SETTINGS, 'TYPO3.Flow.http.baseUri'); |
||
133 | if ($baseUri !== NULL) { |
||
134 | if (method_exists($this->view->getRequest()->getHttpRequest(), 'setBaseUri')) { |
||
135 | $this->view->getRequest()->getHttpRequest()->setBaseUri($baseUri); |
||
0 ignored issues
–
show
|
|||
136 | } |
||
137 | if (method_exists($this->view->getRequest()->getHttpRequest(), 'injectSettings')) { |
||
138 | $this->view->getRequest()->getHttpRequest()->injectSettings(array( |
||
0 ignored issues
–
show
The method
injectSettings() does not seem to exist on object<TYPO3\Flow\Http\Request> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed. ![]() |
|||
139 | 'http' => array( |
||
140 | 'baseUri' => $baseUri |
||
141 | ) |
||
142 | )); |
||
143 | } |
||
144 | } |
||
145 | } |
||
146 | |||
147 | public function setOptionsByViewHelper() { |
||
148 | $viewHelperVariableContainer = $this->view->getViewHelperVariableContainer(); |
||
149 | $settings = array('to', 'from', 'subject'); |
||
150 | foreach ($settings as $setting) { |
||
151 | if ($viewHelperVariableContainer->exists('Famelo\Messaging\ViewHelpers\MessageViewHelper', $setting)) { |
||
152 | $value = $viewHelperVariableContainer->get('Famelo\Messaging\ViewHelpers\MessageViewHelper', $setting); |
||
153 | ObjectAccess::setProperty($this, $setting, $value); |
||
154 | $viewHelperVariableContainer->remove('Famelo\Messaging\ViewHelpers\MessageViewHelper', $setting); |
||
155 | } |
||
156 | } |
||
157 | } |
||
158 | |||
159 | public function test() { |
||
160 | $this->prepare(); |
||
161 | $settings = array('to', 'from', 'subject', 'body'); |
||
162 | echo '<table class="table table-striped table-bordered">'; |
||
163 | foreach ($settings as $setting) { |
||
164 | $value = ObjectAccess::getProperty($this, $setting); |
||
165 | if (is_array($value)) { |
||
166 | $value = implode(' => ', $value); |
||
167 | } |
||
168 | echo '<tr><th>' . $setting . '</th><td>' . $value . '</td></tr>'; |
||
169 | } |
||
170 | echo '</table>'; |
||
171 | } |
||
172 | |||
173 | public function render() { |
||
174 | $this->setSource(); |
||
175 | $this->rawBody = $this->view->render(); |
||
176 | return $this->rawBody; |
||
177 | } |
||
178 | |||
179 | protected function setSource() { |
||
180 | if ($this->source === NULL) { |
||
181 | if ($this->package === NULL) { |
||
182 | $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); |
||
183 | $class = $trace[1]['class']; |
||
184 | preg_match('/([A-Za-z]*)\\\\([A-Za-z]*)/', $class, $match); |
||
185 | $this->package = $match[1] . '.' . $match[2]; |
||
186 | } |
||
187 | |||
188 | $replacements = array( |
||
189 | '@package' => $this->package, |
||
190 | '@message' => $this->message |
||
191 | ); |
||
192 | $template = str_replace(array_keys($replacements), array_values($replacements), $this->templatePath); |
||
193 | $this->view->setTemplatePathAndFilename($template); |
||
194 | |||
195 | $partialRootPath = str_replace(array_keys($replacements), array_values($replacements), $this->partialRootPath); |
||
196 | $this->view->setPartialRootPath($partialRootPath); |
||
197 | } else { |
||
198 | $this->view->setTemplateSource($this->source); |
||
199 | } |
||
200 | } |
||
201 | |||
202 | public function getRawBody() { |
||
203 | return $this->rawBody; |
||
204 | } |
||
205 | |||
206 | public function assign($key, $value) { |
||
207 | $this->view->assign($key, $value); |
||
208 | return $this; |
||
209 | } |
||
210 | |||
211 | public function assignMultiple(array $values) { |
||
212 | foreach ($values as $key => $value) { |
||
213 | $this->assign($key, $value); |
||
214 | } |
||
215 | return $this; |
||
216 | } |
||
217 | |||
218 | public function setTemplateSource($source) { |
||
219 | $this->source = $source; |
||
220 | return $this; |
||
221 | } |
||
222 | |||
223 | public function setRecipientGroup($name) { |
||
224 | $recipients = $this->configurationManager->getConfiguration(\TYPO3\Flow\Configuration\ConfigurationManager::CONFIGURATION_TYPE_SETTINGS, 'Famelo.Messaging.recipients'); |
||
225 | $this->setTo($recipients[$name]); |
||
226 | return $this; |
||
227 | } |
||
228 | } |
||
229 | ?> |
||
0 ignored issues
–
show
It is not recommended to use PHP's closing tag
?> in files other than templates.
Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore. A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever. ![]() |
|||
230 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: