Skip to content

Commit

Permalink
sanitizing
Browse files Browse the repository at this point in the history
  • Loading branch information
ArtificialOwl committed Mar 12, 2020
1 parent 1dd4f83 commit 716d999
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion lib/Service/MailService.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,10 @@ private function verifyInfoAndPassword($content, $toInfo) {
* @throws NotPermittedException
*/
private function getMailFolder($userId, $to, $from) {

$node = \OC::$server->getUserFolder($userId);
$to = $this->parseMailAddress($to);
$from = $this->parseMailAddress($from);

$folderPath = 'Mails sent to ' . $to . '/From ' . $from . '/';

if (!$node->nodeExists($folderPath)) {
Expand Down Expand Up @@ -371,4 +373,25 @@ private function saveMailAddresses($addresses) {
}


/**
* @param string $address
*
* @return string
*/
private function parseMailAddress($address) {
$acceptedChars = 'qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM0123456789@.-_+';

$fixed = '';
for ($i = 0; $i < strlen($address); $i++) {
$c = $address[$i];
if (strpos($acceptedChars, $c) !== false) {
$fixed .= $c;
}
}

$fixed = str_replace('..', '.', $fixed);

return $fixed;
}

}

0 comments on commit 716d999

Please sign in to comment.