From 5059fdcde7a3d0eefb2b11058f3e9e067b60a7e6 Mon Sep 17 00:00:00 2001 From: Christopher Pereira Date: Mon, 25 Oct 2021 18:52:22 -0300 Subject: [PATCH 1/6] Fix chr() ref https://github.com/peachpiecompiler/peachpie/issues/981 --- src/Peachpie.Library/Strings.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Peachpie.Library/Strings.cs b/src/Peachpie.Library/Strings.cs index f123e44366..57e26ef280 100644 --- a/src/Peachpie.Library/Strings.cs +++ b/src/Peachpie.Library/Strings.cs @@ -56,7 +56,7 @@ internal static CharMap InitializeCharMap() /// The character with ASCII code. public static PhpString chr(int bytevalue) { - if (bytevalue < 0xf0) + if (32 <= bytevalue && bytevalue < 128) { return ((char)bytevalue).ToString(); } From c3216a42f6a5f6c9a75447622c8665d540312de4 Mon Sep 17 00:00:00 2001 From: Christopher Pereira Date: Mon, 25 Oct 2021 22:34:36 -0300 Subject: [PATCH 2/6] Added peachpie_set_string_encoding() --- src/Peachpie.Library/Strings.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Peachpie.Library/Strings.cs b/src/Peachpie.Library/Strings.cs index fcbfbd5424..8482a68a7c 100644 --- a/src/Peachpie.Library/Strings.cs +++ b/src/Peachpie.Library/Strings.cs @@ -37,6 +37,11 @@ internal static CharMap InitializeCharMap() #endregion + // Helper function to change Console.OutputEncoding from PHP + public static void peachpie_set_string_encoding(string str) { + Console.OutputEncoding = Encoding.GetEncoding(str); + } + #region ord, chr, bin2hex, hex2bin ///// From 1e44159b1919c3a5910c6c51a3a7672432c48587 Mon Sep 17 00:00:00 2001 From: Christopher Pereira Date: Wed, 7 Sep 2022 18:09:07 -0300 Subject: [PATCH 3/6] Fix C14N Fix: https://github.com/peachpiecompiler/peachpie/issues/1065 --- src/Peachpie.Library.XmlDom/DOMNode.cs | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/Peachpie.Library.XmlDom/DOMNode.cs b/src/Peachpie.Library.XmlDom/DOMNode.cs index e3cb2bdb35..fc1b7e5bca 100644 --- a/src/Peachpie.Library.XmlDom/DOMNode.cs +++ b/src/Peachpie.Library.XmlDom/DOMNode.cs @@ -1,6 +1,8 @@ using System; using System.Collections.Generic; +using System.IO; using System.Linq; +using System.Security.Cryptography.Xml; using System.Text; using System.Xml; using Pchp.Core; @@ -631,11 +633,19 @@ public PhpString C14N( PhpArray xpath = null, PhpArray ns_prefixes = null) { - var transform = new System.Security.Cryptography.Xml.XmlDsigC14NTransform(); - transform.LoadInput(XmlNode.GetXmlDocument()); - var stream = (System.IO.MemoryStream)transform.GetOutput(typeof(System.IO.Stream)); + XmlNodeReader reader = new XmlNodeReader(XmlNode); + Stream inputStream = new MemoryStream(); + XmlWriter writer = new XmlTextWriter(inputStream, Encoding.UTF8); - return new PhpString(stream.ToArray()); + writer.WriteNode(reader, false); + writer.Flush(); + + inputStream.Position = 0; + XmlDsigC14NTransform transform = new XmlDsigC14NTransform(); + transform.LoadInput(inputStream); + + System.IO.MemoryStream outputStream = (System.IO.MemoryStream)transform.GetOutput(typeof(System.IO.Stream)); + return new PhpString(outputStream.ToArray()); } /// From 9def944b72c73007367dcae4636bb56a2a64efca Mon Sep 17 00:00:00 2001 From: Christopher Pereira Date: Wed, 16 Nov 2022 05:02:10 -0300 Subject: [PATCH 4/6] Fix https://github.com/peachpiecompiler/peachpie/issues/1079 --- src/Peachpie.Runtime/Operators.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Peachpie.Runtime/Operators.cs b/src/Peachpie.Runtime/Operators.cs index 33c4504d11..da0bd0c815 100644 --- a/src/Peachpie.Runtime/Operators.cs +++ b/src/Peachpie.Runtime/Operators.cs @@ -2411,8 +2411,13 @@ public static PhpValue Eval(Context ctx, PhpArray locals, object @this, RuntimeT }, code); - // - return script.Evaluate(ctx, locals, @this, self); + try { + return script.Evaluate(ctx, locals, @this, self); + + } catch (Pchp.Core.PhpFatalErrorException e) { + PhpException.Throw(PhpError.Warning, e.Message); + return false; + } } #endregion From 85f6d7bdc7f86af067ca23669487383f722077d6 Mon Sep 17 00:00:00 2001 From: Christopher Pereira Date: Wed, 16 Nov 2022 17:13:51 -0300 Subject: [PATCH 5/6] Added Peachpie.Library.PDO.PgSQL to dummy.msbuildproj --- build/dummy/dummy.msbuildproj | 1 + build/update-cache.ps1 | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/build/dummy/dummy.msbuildproj b/build/dummy/dummy.msbuildproj index a0a5277f52..3ada67aece 100644 --- a/build/dummy/dummy.msbuildproj +++ b/build/dummy/dummy.msbuildproj @@ -9,6 +9,7 @@ + diff --git a/build/update-cache.ps1 b/build/update-cache.ps1 index a323198be5..f91f988c61 100644 --- a/build/update-cache.ps1 +++ b/build/update-cache.ps1 @@ -13,7 +13,7 @@ $defaultArgs = "/p:VersionPrefix=$version,VersionSuffix=$suffix" ## Delete old nuget packages Write-Host -f green "Deleting '$version-$suffix' packages from '$packagesSource' ..." -@("Peachpie.Runtime", "Peachpie.Library", "Peachpie.Library.Scripting", "Peachpie.Library.MySql", "Peachpie.Library.MsSql", "Peachpie.Library.Graphics", "Peachpie.Library.Network", "Peachpie.Library.PDO", "Peachpie.Library.XmlDom", "Peachpie.App", "Peachpie.CodeAnalysis", "Peachpie.AspNetCore.Web", "Peachpie.RequestHandler", "Peachpie.AspNetCore.Mvc", "Peachpie.NET.Sdk", "Peachpie.Library.PDO.MySql", "Peachpie.Library.PDO.Sqlite", "Peachpie.Library.SqlSrv") | % { +@("Peachpie.Runtime", "Peachpie.Library", "Peachpie.Library.Scripting", "Peachpie.Library.MySql", "Peachpie.Library.MsSql", "Peachpie.Library.Graphics", "Peachpie.Library.Network", "Peachpie.Library.PDO", "Peachpie.Library.XmlDom", "Peachpie.App", "Peachpie.CodeAnalysis", "Peachpie.AspNetCore.Web", "Peachpie.RequestHandler", "Peachpie.AspNetCore.Mvc", "Peachpie.NET.Sdk", "Peachpie.Library.PDO.PgSQL", "Peachpie.Library.PDO.MySql", "Peachpie.Library.PDO.Sqlite", "Peachpie.Library.SqlSrv") | % { $installedFolder = "$packagesSource/$_/$version-$suffix" if (Test-Path $installedFolder) { Remove-Item -Recurse -Force $installedFolder From 280800183060e500a1c0ae0020663ec1b7536970 Mon Sep 17 00:00:00 2001 From: Christopher Pereira Date: Wed, 16 Nov 2022 17:38:21 -0300 Subject: [PATCH 6/6] Revert "Added peachpie_set_string_encoding()" This reverts commit c3216a42f6a5f6c9a75447622c8665d540312de4. --- src/Peachpie.Library/Strings.cs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/Peachpie.Library/Strings.cs b/src/Peachpie.Library/Strings.cs index ce68924b85..488ba1383f 100644 --- a/src/Peachpie.Library/Strings.cs +++ b/src/Peachpie.Library/Strings.cs @@ -37,11 +37,6 @@ internal static CharMap InitializeCharMap() #endregion - // Helper function to change Console.OutputEncoding from PHP - public static void peachpie_set_string_encoding(string str) { - Console.OutputEncoding = Encoding.GetEncoding(str); - } - #region ord, chr, bin2hex, hex2bin /////