Skip to content

Commit

Permalink
Merge pull request #115 from iosley/master
Browse files Browse the repository at this point in the history
#109 Fix spaces on Outlook
  • Loading branch information
lptn authored Mar 5, 2021
2 parents 659a682 + cb9707f commit 0586c13
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 7 deletions.
26 changes: 23 additions & 3 deletions src/Generators/WebOutlook.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,36 @@ public function generate(Link $link): string
$url .= '&allday=true';
}

$url .= '&subject='.urlencode($link->title);
$url .= '&subject='.urlencode($this->sanitizeText($link->title));

if ($link->description) {
$url .= '&body='.urlencode($link->description);
$url .= '&body='.urlencode($this->sanitizeText($link->description));
}

if ($link->address) {
$url .= '&location='.urlencode($link->address);
$url .= '&location='.urlencode($this->sanitizeText($link->address));

This comment has been minimized.

Copy link
@dravenk

dravenk Feb 13, 2022

Contributor

The Location field does not require character conversions. The code below is correct.

$url .= '&location='.urlencode($link->address);

If adding $this->sanitizeText to convert location filed there will be an additional   character.

}

return $url;
}

/**
* Generate an text without html entity code and hexadecimal code instead spaces.
* @param string $text
* @return string
*/
private function sanitizeText(string $text): string
{
$replaceList = [
'/\s/' => ' ',
];

$resultText = html_entity_decode($text);

foreach ($replaceList as $pattern => $newValue) {
$resultText = preg_replace($pattern, $newValue, $resultText);
}

return $resultText;
}
}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return 'https://outlook.live.com/calendar/deeplink/compose?path=/calendar/action/compose&rru=addevent&startdt=2019-12-31T23:00:00Z&enddt=2020-01-01T01:00:00Z&subject=New+Year&body=With+balloons%2C+clowns+and+stuff%0ABring+a+dog%2C+bring+a+frog&location=Party+Lane+1A%2C+1337+Funtown';
<?php return 'https://outlook.live.com/calendar/deeplink/compose?path=/calendar/action/compose&rru=addevent&startdt=2019-12-31T23:00:00Z&enddt=2020-01-01T01:00:00Z&subject=New%26%2332%3BYear&body=With%26%2332%3Bballoons%2C%26%2332%3Bclowns%26%2332%3Band%26%2332%3Bstuff%26%2332%3BBring%26%2332%3Ba%26%2332%3Bdog%2C%26%2332%3Bbring%26%2332%3Ba%26%2332%3Bfrog&location=Party%26%2332%3BLane%26%2332%3B1A%2C%26%2332%3B1337%26%2332%3BFuntown';
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return 'https://outlook.live.com/calendar/deeplink/compose?path=/calendar/action/compose&rru=addevent&startdt=2018-02-01&enddt=2018-02-06&allday=true&subject=Birthday&body=With+balloons%2C+clowns+and+stuff%0ABring+a+dog%2C+bring+a+frog&location=Party+Lane+1A%2C+1337+Funtown';
<?php return 'https://outlook.live.com/calendar/deeplink/compose?path=/calendar/action/compose&rru=addevent&startdt=2018-02-01&enddt=2018-02-06&allday=true&subject=Birthday&body=With%26%2332%3Bballoons%2C%26%2332%3Bclowns%26%2332%3Band%26%2332%3Bstuff%26%2332%3BBring%26%2332%3Ba%26%2332%3Bdog%2C%26%2332%3Bbring%26%2332%3Ba%26%2332%3Bfrog&location=Party%26%2332%3BLane%26%2332%3B1A%2C%26%2332%3B1337%26%2332%3BFuntown';
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return 'https://outlook.live.com/calendar/deeplink/compose?path=/calendar/action/compose&rru=addevent&startdt=2018-02-01T09:00:00Z&enddt=2018-02-01T18:00:00Z&subject=Birthday&body=With+balloons%2C+clowns+and+stuff%0ABring+a+dog%2C+bring+a+frog&location=Party+Lane+1A%2C+1337+Funtown';
<?php return 'https://outlook.live.com/calendar/deeplink/compose?path=/calendar/action/compose&rru=addevent&startdt=2018-02-01T09:00:00Z&enddt=2018-02-01T18:00:00Z&subject=Birthday&body=With%26%2332%3Bballoons%2C%26%2332%3Bclowns%26%2332%3Band%26%2332%3Bstuff%26%2332%3BBring%26%2332%3Ba%26%2332%3Bdog%2C%26%2332%3Bbring%26%2332%3Ba%26%2332%3Bfrog&location=Party%26%2332%3BLane%26%2332%3B1A%2C%26%2332%3B1337%26%2332%3BFuntown';
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return 'https://outlook.live.com/calendar/deeplink/compose?path=/calendar/action/compose&rru=addevent&startdt=2018-02-01&enddt=2018-02-02&allday=true&subject=Birthday&body=With+balloons%2C+clowns+and+stuff%0ABring+a+dog%2C+bring+a+frog&location=Party+Lane+1A%2C+1337+Funtown';
<?php return 'https://outlook.live.com/calendar/deeplink/compose?path=/calendar/action/compose&rru=addevent&startdt=2018-02-01&enddt=2018-02-02&allday=true&subject=Birthday&body=With%26%2332%3Bballoons%2C%26%2332%3Bclowns%26%2332%3Band%26%2332%3Bstuff%26%2332%3BBring%26%2332%3Ba%26%2332%3Bdog%2C%26%2332%3Bbring%26%2332%3Ba%26%2332%3Bfrog&location=Party%26%2332%3BLane%26%2332%3B1A%2C%26%2332%3B1337%26%2332%3BFuntown';

0 comments on commit 0586c13

Please sign in to comment.