Skip to content

Commit

Permalink
Synchronizing with symfony svn
Browse files Browse the repository at this point in the history
  • Loading branch information
vjousse committed Sep 16, 2011
1 parent e5c5051 commit aa7e9e4
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 15 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG
Original file line number Original file line Diff line number Diff line change
@@ -1,3 +1,14 @@
09/16/11: Version 1.4.14
------------------------

* [33025] fixed sfCacheSessionStorage does not always check whether HTTP_USER_AGENT is set (closes #9921, patch from boutell)
* [33022] fixed auto_link_text() when an email address is already linked (closes #9915, based on a patch from klemens_u)
* [33021] fixed sfCacheSessionStorage does not serialize properly, also uses wrong option name for httponly (closes #9919, based on a patch from boutell)
* [32939] fixed memory leak in sfRoute::generate() (closes #9886 - patch from acf0)
* [32892] fixed Doctrine form generation when a schema has abstract tables (closes #9885 - patch from chok)
* [32891] fixed sfFinder bug when mirroring file with twice the path inside it (closes #9892 - based on a patch from shordeaux)
* [32890] fixed bad value of property 'list-style' in css of WebDebug toolbar (closes #9891 - patch from tomi)

08/05/11: Version 1.4.13 08/05/11: Version 1.4.13
------------------------ ------------------------


Expand Down
2 changes: 1 addition & 1 deletion lib/autoload/sfCoreAutoload.class.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
/** /**
* The current symfony version. * The current symfony version.
*/ */
define('SYMFONY_VERSION', '1.4.14-DEV'); define('SYMFONY_VERSION', '1.4.15-DEV');


/** /**
* sfCoreAutoload class. * sfCoreAutoload class.
Expand Down
9 changes: 7 additions & 2 deletions lib/helper/TextHelper.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* @subpackage helper * @subpackage helper
* @author Fabien Potencier <fabien.potencier@symfony-project.com> * @author Fabien Potencier <fabien.potencier@symfony-project.com>
* @author David Heinemeier Hansson * @author David Heinemeier Hansson
* @version SVN: $Id: TextHelper.php 31895 2011-01-24 18:37:43Z fabien $ * @version SVN: $Id: TextHelper.php 33022 2011-09-15 05:27:12Z fabien $
*/ */


/** /**
Expand Down Expand Up @@ -283,5 +283,10 @@ function _auto_link_urls($text, $href_options = array(), $truncate = false, $tru
*/ */
function _auto_link_email_addresses($text) function _auto_link_email_addresses($text)
{ {
return preg_replace('/([\w\.!#\$%\-+.]+@[A-Za-z0-9\-]+(\.[A-Za-z0-9\-]+)+)/', '<a href="mailto:\\1">\\1</a>', $text); // Taken from http://snippets.dzone.com/posts/show/6156
return preg_replace("#(^|[\n ])([a-z0-9&\-_\.]+?)@([\w\-]+\.([\w\-\.]+\.)*[\w]+)#i", "\\1<a href=\"mailto:\\2@\\3\">\\2@\\3</a>", $text);

// Removed since it destroys already linked emails
// Example: <a href="mailto:me@example.com">bar</a> gets <a href="mailto:me@example.com">bar</a> gets <a href="mailto:<a href="mailto:me@example.com">bar</a>
//return preg_replace('/([\w\.!#\$%\-+.]+@[A-Za-z0-9\-]+(\.[A-Za-z0-9\-]+)+)/', '<a href="mailto:\\1">\\1</a>', $text);
} }
41 changes: 32 additions & 9 deletions lib/storage/sfCacheSessionStorage.class.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -40,12 +40,20 @@ class sfCacheSessionStorage extends sfStorage
public function initialize($options = array()) public function initialize($options = array())
{ {
// initialize parent // initialize parent

// bc with a slightly different name formerly used here, let's be
// compatible with the base class name for it from here on out
if (isset($options['session_cookie_http_only']))
{
$options['session_cookie_httponly'] = $options['session_cookie_http_only'];
}

parent::initialize(array_merge(array('session_name' => 'sfproject', parent::initialize(array_merge(array('session_name' => 'sfproject',
'session_cookie_lifetime' => '+30 days', 'session_cookie_lifetime' => '+30 days',
'session_cookie_path' => '/', 'session_cookie_path' => '/',
'session_cookie_domain' => null, 'session_cookie_domain' => null,
'session_cookie_secure' => false, 'session_cookie_secure' => false,
'session_cookie_http_only' => true, 'session_cookie_httponly' => true,
'session_cookie_secret' => 'sf$ecret'), $options)); 'session_cookie_secret' => 'sf$ecret'), $options));


// create cache instance // create cache instance
Expand Down Expand Up @@ -108,14 +116,28 @@ public function initialize($options = array())
$this->options['session_cookie_path'], $this->options['session_cookie_path'],
$this->options['session_cookie_domain'], $this->options['session_cookie_domain'],
$this->options['session_cookie_secure'], $this->options['session_cookie_secure'],
$this->options['session_cookie_http_only']); $this->options['session_cookie_httponly']);


$this->data = array(); $this->data = array();
} }
else else
{ {
// load data from cache // load data from cache. Watch out for the default case. We could
$this->data = $this->cache->get($this->id, array()); // serialize(array()) as the default to the call but that would be a performance hit
$raw = $this->cache->get($this->id, null);
if (is_null($raw))
{
$this->data = array();
}
elseif (is_array($raw))
{
// probably an old cached value (BC)
$this->data = $raw;
}
else
{
$this->data = unserialize($raw);
}


if(sfConfig::get('sf_logging_enabled')) if(sfConfig::get('sf_logging_enabled'))
{ {
Expand Down Expand Up @@ -208,10 +230,12 @@ public function regenerate($destroy = false)
} }


// generate session id // generate session id
$this->id = md5(rand(0, 999999).$_SERVER['REMOTE_ADDR'].$_SERVER['HTTP_USER_AGENT'].$this->options['session_cookie_secret']); $ua = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : 'ua';

$this->id = md5(rand(0, 999999).$_SERVER['REMOTE_ADDR'].$ua.$this->options['session_cookie_secret']);


// save data to cache // save data to cache
$this->cache->set($this->id, $this->data); $this->cache->set($this->id, serialize($this->data));


// update session id in signed cookie // update session id in signed cookie
$this->response->setCookie($this->options['session_name'], $this->response->setCookie($this->options['session_name'],
Expand All @@ -220,7 +244,7 @@ public function regenerate($destroy = false)
$this->options['session_cookie_path'], $this->options['session_cookie_path'],
$this->options['session_cookie_domain'], $this->options['session_cookie_domain'],
$this->options['session_cookie_secure'], $this->options['session_cookie_secure'],
$this->options['session_cookie_http_only']); $this->options['session_cookie_httponly']);
session_id($this->id); session_id($this->id);
return true; return true;
} }
Expand Down Expand Up @@ -249,11 +273,10 @@ public function shutdown()
// only update cache if session has changed // only update cache if session has changed
if($this->dataChanged === true) if($this->dataChanged === true)
{ {
$this->cache->set($this->id, $this->data); $this->cache->set($this->id, serialize($this->data));
if(sfConfig::get('sf_logging_enabled')) if(sfConfig::get('sf_logging_enabled'))
{ {
$this->dispatcher->notify(new sfEvent($this, 'application.log', array('Storing session to cache'))); $this->dispatcher->notify(new sfEvent($this, 'application.log', array('Storing session to cache')));
// $this->dispatcher->notify(new sfEvent($this, 'application.log', array(var_export($this->data, true))));
} }
} }
} }
Expand Down
5 changes: 3 additions & 2 deletions test/unit/helper/TextHelperTest.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
require_once(dirname(__FILE__).'/../../../lib/helper/TagHelper.php'); require_once(dirname(__FILE__).'/../../../lib/helper/TagHelper.php');
require_once(dirname(__FILE__).'/../../../lib/helper/TextHelper.php'); require_once(dirname(__FILE__).'/../../../lib/helper/TextHelper.php');


$t = new lime_test(54); $t = new lime_test(56);


// truncate_text() // truncate_text()
$t->diag('truncate_text()'); $t->diag('truncate_text()');
Expand Down Expand Up @@ -134,4 +134,5 @@
$t->is(auto_link_text('<p>http://www.google.com/?q=symfony+link</p>', 'all', array(), true, 32, '***'), '<p><a href="http://www.google.com/?q=symfony+link">http://www.google.com/?q=symfony***</a></p>', 'auto_link_text() takes truncation parameters'); $t->is(auto_link_text('<p>http://www.google.com/?q=symfony+link</p>', 'all', array(), true, 32, '***'), '<p><a href="http://www.google.com/?q=symfony+link">http://www.google.com/?q=symfony***</a></p>', 'auto_link_text() takes truncation parameters');
$t->is(auto_link_text('<p>http://twitter.com/#!/fabpot</p>'),'<p><a href="http://twitter.com/#!/fabpot">http://twitter.com/#!/fabpot</a></p>',"auto_link_text() converts URLs with complex fragments to links"); $t->is(auto_link_text('<p>http://twitter.com/#!/fabpot</p>'),'<p><a href="http://twitter.com/#!/fabpot">http://twitter.com/#!/fabpot</a></p>',"auto_link_text() converts URLs with complex fragments to links");
$t->is(auto_link_text('<p>http://twitter.com/#!/fabpot is Fabien Potencier on Twitter</p>'),'<p><a href="http://twitter.com/#!/fabpot">http://twitter.com/#!/fabpot</a> is Fabien Potencier on Twitter</p>',"auto_link_text() converts URLs with complex fragments and trailing text to links"); $t->is(auto_link_text('<p>http://twitter.com/#!/fabpot is Fabien Potencier on Twitter</p>'),'<p><a href="http://twitter.com/#!/fabpot">http://twitter.com/#!/fabpot</a> is Fabien Potencier on Twitter</p>',"auto_link_text() converts URLs with complex fragments and trailing text to links");

$t->is(auto_link_text('hello '.$email_result, 'email_addresses'), 'hello '.$email_result, "auto_link_text() does not double-link emails");
$t->is(auto_link_text('<p>Link '.$link_result.'</p>'), '<p>Link '.$link_result.'</p>', "auto_link_text() does not double-link emails");
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
// Test for ICU Upgrade and Ticket #7988 // Test for ICU Upgrade and Ticket #7988
// should be 0. Tests will break after ICU Update, which is fine. change count to 0 // should be 0. Tests will break after ICU Update, which is fine. change count to 0
$t->is(count($css->matchAll('#country option[value="ZZ"]')), 1, '->render() does not contain dummy data'); $t->is(count($css->matchAll('#country option[value="ZZ"]')), 1, '->render() does not contain dummy data');
$t->is(count($css->matchAll('#country option[value="419"]')), 1, '->render() does not contain region data'); $t->is(count($css->matchAll('#country option[value="419"]')), 0, '->render() does not contain region data');


// add_empty // add_empty
$t->diag('add_empty'); $t->diag('add_empty');
Expand Down

0 comments on commit aa7e9e4

Please sign in to comment.