problem with & in link url

Use this forum for questions regarding adoption and functionality of OpenEMM

Moderator: moderator

csl-computer
Posts: 6
Joined: Fri Mar 28, 2008 8:48 am

problem with & in link url

Post by csl-computer »

I want to send a utf8/xhtml mailing with openemm. Links inside the mailing have some parameters attached with an "&" as it is standard in utf8/xhtml. Using these links in a browser works fine, because the browser replaces the "&" with "&". I have a problem that the link tracker redirection uses "&" instead of "&" for the redirected url.
So even the link to edit the user profile in openemm doesn't work. The error message is "form not found":
The link looks like:
http://mail3.csl-computer.com/form.do?a ... il&agnUID=...

When I delete the "amp;" manually in the browser the link works perfectly fine (http://mail3.csl-computer.com/form.do?a ... il&agnUID=...).
Is there any possibility to make openemm work as expected?

Best regards

Dennis
christian.lang
Posts: 30
Joined: Thu Apr 19, 2007 3:24 pm

&amp Problem

Post by christian.lang »

This Problem has been discussed several times so far.
There is also a Bug-Tracker Entry for this
http://sourceforge.net/tracker/index.ph ... tid=848488

The problem occurs if the HTML Code for the Mailing is created outside OpenEMM - for example in some kind of Content-Management System - and is then copied to OpenEMM.
A CMS often creates Links with & instead of & because of the standards you mentioned.

I agree to your comment, that - in my opinion - OpenEMM unfortunately doesn't parse this kind of links correctly.
csl-computer
Posts: 6
Joined: Fri Mar 28, 2008 8:48 am

workaround

Post by csl-computer »

I wrote a little script in PHP to work around this "bug"!
For everyone who has the same problem ... this is the code:

Code: Select all

<html>
<head>
<title>OpenEMM Redirection URL Korrektur &copy; by Dennis M&ouml;ller</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body>
	<h1>OpenEMM Redirection URL Korrektur</h1><br />
<?php
// Datei zum korrigieren der & Problematik in Redirect Links
// Autor: Dennis Möller, CSL-Computer GmbH & Co. KG, Datum: 30.03.2008

require("DB.php");

$DEBUG = FALSE;

$mysql_server = "mysql://USER:PASSWORD@localhost/openemm";
$verbindung = DB::connect($mysql_server);
if (DB::isError($verbindung)) die("Keine Verbindung zur MySQL Datenbank!<br />".$verbindung->getMessage());

$sql = "SELECT full_url, url_id FROM rdir_url_tbl WHERE 1 ORDER BY url_id DESC";

$result = $verbindung->query($sql);
$count_all = $result->numRows();
$count_edited = 0;

if ($count_all > 0){
	while ($data = $result->fetchRow(DB_FETCHMODE_ASSOC)){
		if (preg_match('/\&/', $data['full_url'])){
			$count_edited++;
			
			$replaced = preg_replace('/\&/', '&', $data['full_url']);
			$update_sql = "UPDATE rdir_url_tbl SET full_url='".$replaced."' WHERE url_id=".$data['url_id'];
			$verbindung->query($update_sql);
			if ($DEBUG){ echo $count_edited.": ".$update_sql.'<br /><br />';}
			else {};
			
			
		}
	}
	echo '<br /><br />'.$count_edited.' von '.$count_all.' korrigiert!';
}
$verbindung->disconnect();
?>
</body>
</html>
Post Reply