Note that there are some explanatory texts on larger screens.

plurals
  1. POspaces or %20 in links turn into + signs when page is sent as an email
    text
    copied!<p>I am creating a web app that accepts input of news items (title, article, url). It has a page <code>news.php</code> which creates a summary of all news items inputted for specified dates, like so:</p> <pre><code>News 4/25/2010 Title 1 [URL 1] Article 1 Title 2 [URL 2] Article 2 </code></pre> <p>and so on...</p> <p>I have two other pages, namely <code>preview.php</code> and <code>send.php</code> , both of which call news.php through a <code>file_get_contents()</code> call.</p> <p>Everything works fine except when the URL contains spaces. During Preview, the urls get opened (FF: spaces are spaces, Chrome: spaces are %20). However, during Send, when received as emails, the urls don't get opened, because the spaces are converted into + signs.</p> <p>For example:</p> <blockquote> <ol> <li>Preview in FF: <a href="http://www.example.com/this" rel="nofollow noreferrer">http://www.example.com/this</a> is the link.html</li> <li>Preview in Chrome: <a href="http://www.example.com/this%20is%20the%20link.html" rel="nofollow noreferrer">http://www.example.com/this%20is%20the%20link.html</a></li> <li>Viewed as email in both browsers: <a href="http://www.example.com/this+is+the+link.html" rel="nofollow noreferrer">http://www.example.com/this+is+the+link.html</a></li> </ol> </blockquote> <p>Only #3 doesn't work (link doesn't get opened).</p> <p>Why are the spaces in the urls correct (spaces or %20) when previewed, but incorrect (+) when received in the emails, when in fact, the same page is generated by the same news.php?</p> <p>Any help appreciated :)</p> <hr> <p>EDIT:</p> <p>preview.php:</p> <pre><code>$HTML_version = file_get_contents('news.php'); echo $HTML_version; </code></pre> <p>send.php</p> <pre><code>$HTML_version = file_get_contents('news.php'); $body = "$notice_text --$mime_boundary Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit $TEXT_version --$mime_boundary Content-Type: text/html; charset=us-ascii Content-Transfer-Encoding: 7bit $HTML_version --$mime_boundary--"; //some other code here to send the email </code></pre> <p>news.php:</p> <pre><code>&lt;a href="&lt;?php echo $url ?&gt;"&gt;attachment&lt;/a&gt; //the $url there contains spaces </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload