Author: fabien
Date: 2010-03-29 12:43:49 +0200 (Mon, 29 Mar 2010)
New Revision: 28856
Modified:
components/yaml/branches/1.0/lib/sfYamlInline.php
components/yaml/branches/1.0/lib/sfYamlParser.php
components/yaml/trunk/lib/sfYamlInline.php
components/yaml/trunk/lib/sfYamlParser.php
Log:
[YAML] fixed YAML parser when mbstring.func_overload is used with an
mbstring.internal_encoding different from ASCII (closes #3933)
Modified: components/yaml/branches/1.0/lib/sfYamlInline.php
===================================================================
--- components/yaml/branches/1.0/lib/sfYamlInline.php 2010-03-29 10:38:27 UTC
(rev 28855)
+++ components/yaml/branches/1.0/lib/sfYamlInline.php 2010-03-29 10:43:49 UTC
(rev 28856)
@@ -38,15 +38,30 @@
return '';
}
+ if (function_exists('mb_internal_encoding') && ((int)
ini_get('mbstring.func_overload')) & 2)
+ {
+ $mbEncoding = mb_internal_encoding();
+ mb_internal_encoding('ASCII');
+ }
+
switch ($value[0])
{
case '[':
- return self::parseSequence($value);
+ $result = self::parseSequence($value);
+ break;
case '{':
- return self::parseMapping($value);
+ $result = self::parseMapping($value);
+ break;
default:
- return self::parseScalar($value);
+ $result = self::parseScalar($value);
}
+
+ if (isset($mbEncoding))
+ {
+ mb_internal_encoding($mbEncoding);
+ }
+
+ return $result;
}
/**
Modified: components/yaml/branches/1.0/lib/sfYamlParser.php
===================================================================
--- components/yaml/branches/1.0/lib/sfYamlParser.php 2010-03-29 10:38:27 UTC
(rev 28855)
+++ components/yaml/branches/1.0/lib/sfYamlParser.php 2010-03-29 10:43:49 UTC
(rev 28856)
@@ -57,6 +57,12 @@
$this->currentLine = '';
$this->lines = explode("\n", $this->cleanup($value));
+ if (function_exists('mb_internal_encoding') && ((int)
ini_get('mbstring.func_overload')) & 2)
+ {
+ $mbEncoding = mb_internal_encoding();
+ mb_internal_encoding('ASCII');
+ }
+
$data = array();
while ($this->moveToNextLine())
{
@@ -214,6 +220,11 @@
}
}
+ if (isset($mbEncoding))
+ {
+ mb_internal_encoding($mbEncoding);
+ }
+
return $value;
}
@@ -247,6 +258,11 @@
}
}
+ if (isset($mbEncoding))
+ {
+ mb_internal_encoding($mbEncoding);
+ }
+
return empty($data) ? null : $data;
}
Modified: components/yaml/trunk/lib/sfYamlInline.php
===================================================================
--- components/yaml/trunk/lib/sfYamlInline.php 2010-03-29 10:38:27 UTC (rev
28855)
+++ components/yaml/trunk/lib/sfYamlInline.php 2010-03-29 10:43:49 UTC (rev
28856)
@@ -38,15 +38,30 @@
return '';
}
+ if (function_exists('mb_internal_encoding') && ((int)
ini_get('mbstring.func_overload')) & 2)
+ {
+ $mbEncoding = mb_internal_encoding();
+ mb_internal_encoding('ASCII');
+ }
+
switch ($value[0])
{
case '[':
- return self::parseSequence($value);
+ $result = self::parseSequence($value);
+ break;
case '{':
- return self::parseMapping($value);
+ $result = self::parseMapping($value);
+ break;
default:
- return self::parseScalar($value);
+ $result = self::parseScalar($value);
}
+
+ if (isset($mbEncoding))
+ {
+ mb_internal_encoding($mbEncoding);
+ }
+
+ return $result;
}
/**
Modified: components/yaml/trunk/lib/sfYamlParser.php
===================================================================
--- components/yaml/trunk/lib/sfYamlParser.php 2010-03-29 10:38:27 UTC (rev
28855)
+++ components/yaml/trunk/lib/sfYamlParser.php 2010-03-29 10:43:49 UTC (rev
28856)
@@ -57,6 +57,12 @@
$this->currentLine = '';
$this->lines = explode("\n", $this->cleanup($value));
+ if (function_exists('mb_internal_encoding') && ((int)
ini_get('mbstring.func_overload')) & 2)
+ {
+ $mbEncoding = mb_internal_encoding();
+ mb_internal_encoding('ASCII');
+ }
+
$data = array();
while ($this->moveToNextLine())
{
@@ -227,6 +233,11 @@
}
}
+ if (isset($mbEncoding))
+ {
+ mb_internal_encoding($mbEncoding);
+ }
+
return $value;
}
@@ -260,6 +271,11 @@
}
}
+ if (isset($mbEncoding))
+ {
+ mb_internal_encoding($mbEncoding);
+ }
+
return empty($data) ? null : $data;
}
--
You received this message because you are subscribed to the Google Groups
"symfony SVN" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/symfony-svn?hl=en.