Skip to content

Commit

Permalink
Fixed issue #17195: When attaching PDF to email invitation, full path…
Browse files Browse the repository at this point in the history
… is kept as value of a hidden input (#1836)
  • Loading branch information
gabrieljenik committed Apr 7, 2021
1 parent 32ddd29 commit dba2894
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions application/controllers/admin/emailtemplates.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,21 @@ function index($iSurveyId)
} else {
$sEscapeMode = 'unescaped';
}
$uploadDir = realpath(Yii::app()->getConfig('uploaddir'));
foreach ($grplangs as $key => $grouplang) {
$aData['bplangs'][$key] = $grouplang;
$aData['attrib'][$key] = SurveyLanguageSetting::model()->find('surveyls_survey_id = :ssid AND surveyls_language = :ls', array(':ssid' => $iSurveyId, ':ls' => $grouplang));
$aData['attrib'][$key]['attachments'] = unserialize($aData['attrib'][$key]['attachments']);
$attachments = unserialize($aData['attrib'][$key]['attachments']);
if (is_array($attachments)) {
foreach ($attachments as &$template) {
foreach ($template as &$attachment) {
if (substr($attachment['url'], 0, strlen($uploadDir)) == $uploadDir) {
$attachment['url'] = str_replace('\\', '/', substr($attachment['url'], strlen($uploadDir)));
}
}
}
}
$aData['attrib'][$key]['attachments'] = $attachments;
$aData['defaulttexts'][$key] = templateDefaultTexts($aData['bplangs'][$key], $sEscapeMode);
}

Expand Down Expand Up @@ -123,7 +134,7 @@ function update($iSurveyId)
foreach ($_POST['attachments'][$langname] as $template => &$attachments) {
foreach ($attachments as $index => &$attachment) {
// We again take the real path.
$localName = realpath(urldecode(str_replace($uploadUrl, $uploadDir, $attachment['url'])));
$localName = realpath(urldecode($uploadDir . str_replace($uploadUrl, '', $attachment['url'])));
if ($localName !== false) {
if (strpos($localName, $uploadDir) === 0) {
$attachment['url'] = $localName;
Expand Down

1 comment on commit dba2894

@Shnoulle
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix windows issue too :)

  • 16905: Windows server : good attachment throw JS error (and broke all JS action)
  • 16903: Windows server : unable to save attachements

Please sign in to comment.