nicoknoll/MarkupSEO

Custom tags not working on windows server

joeck opened this issue · 4 comments

joeck commented

Custom tags are not working on a windows server (IIS).
Specifically, the command PHP_EOL is not working on line 426 in MarkupSEO.module:

private function parseCustom($custom) {
	if(trim($custom) == '') return;
	$return = '';
	$lines = explode(PHP_EOL, $custom);
	foreach($lines as $line) {
		list($key, $value) = explode(':=', $line);
		$key = preg_replace('%[^A-Za-z0-9\-\.\:\_]+%', '', str_replace(' ', '-', trim($key)));	
		$value = trim(wire('sanitizer')->text(html_entity_decode($value)));
		$return[$key] = $value;
	}
	return $return;
}

I changed the delimiter from PHP_EOL to \n and it is now working.
Working code:

private function parseCustom($custom) {
	if(trim($custom) == '') return;
	$return = '';
	$lines = explode("\n", $custom);
	foreach($lines as $line) {
		list($key, $value) = explode(':=', $line);
		$key = preg_replace('%[^A-Za-z0-9\-\.\:\_]+%', '', str_replace(' ', '-', trim($key)));	
		$value = trim(wire('sanitizer')->text(html_entity_decode($value)));
		$return[$key] = $value;
	}
	return $return;
}

I didn't test this on other systems but apparently there are common issues with PHP_EOL
source: https://stackoverflow.com/questions/5508454/how-to-resolve-php-php-eol-issue

@joeck - check out my fork which includes this fix along with many other fixes and new features: https://github.com/adrianbj/MarkupSEO/tree/various-fixes-enhancements

joeck commented

@adrianbj thank you for linking your fork. Do you have documentation of the new features and fixes? And did you already perform some tests and use it productively?

Sorry, the only documentation is what you can garner from my commit logs. I don't have time to commit to supporting it, but given that Nico is no longer working on this version at all, I figure it's still a better option. My fork is being used on a large / high volume. high profile destination marketing site with no problems.

Perhaps you might also consider @wanze 's new module: https://github.com/wanze/SeoMaestro

joeck commented

No need to be sorry, I really appreciate the work you did on your fork. I was just curious and would have wanted to take a look if there is documentation.

I did have a look at SeoMaestro but since all the data from the MarkupSEO module is already in the database, I really don't want to fill in all the data again for SeoMaestro. Thanks for the link though!