字符串问题 - 长度不正确 - 包含的某些字符未显示
我想升级 Magento Ogone 模块以匹配新的 SHASign 计算。 现在工作正常,但有一个问题...
我对 Magento 方法返回的一些字符串有疑问: Mage::getUrl('ogone/api/accept');
它返回一个字符串,其中包含一些不会在屏幕上打印的字符。我不知道为什么。
string(89) "ACCEPTURL=http://www.xxxxxxx.be/store/fr_be/ogone/api/accept/KKKKKKKKKKKKKKKKKKKK"
KKKK = 来自 ogone 的秘密代码
如果您检查长度不是 89 而是 80。 有一些隐藏的汽车,如果我执行 for 循环并一一回显字符,我就可以看到它们。
未显示的字符是: ?___SID=U 我检查了 Magento,URL 中的会话 id 参数已被禁用。
在模块中,我需要获取发送到 Ogone 的所有表单字段,并创建一个 SHA-1 字符串,以确保数据完整性,该字符串仅对我和 Ogone 可用。 对于这个问题,我这边构建的 SHA-1 字符串与 Ogone 不一样,因为表单中的 URL 显示时没有 ?___SID=U :告诉你它不会被打印!
所以首先我不知道为什么当我在配置中要求 Magento 不包含它时。 其次,为什么我看不到 var_dump() 或任何 echo 上的字符?
我该如何调试这种情况?我想有一些功能可以帮助我。
我用另一个函数修复了这个问题来构建 URL,这样我的 SHA-1 字符串就知道了,并且模块看起来工作正常。我的担忧更集中于 strlen 函数和哈希函数看到的那些隐藏字符,而不是 echo 或任何其他打印函数。
感谢您的帮助,请原谅我的英语不好,不是我的母语。
I wanted to upgrade the Magento Ogone module to match the new SHASign calculation.
It's working fine now but there is a problem ...
I have an issue with some strings returned by a Magento method : Mage::getUrl('ogone/api/accept');
It returns me a string with some chars that won't print at the screen. I don't know why.
string(89) "ACCEPTURL=http://www.xxxxxxx.be/store/fr_be/ogone/api/accept/KKKKKKKKKKKKKKKKKKK"
KKKK = secret code from ogone
If you check the lenght is not 89 but 80.
There are some hidden cars, I can see them if I do a for loop and echo one by one the chars.
The chars not displayed are : ?___SID=U
I checked in Magento and the session id parameter in URL was already disabled.
In the module I need to fetch all form fields sent to Ogone and create a SHA-1 string to ensure data integrity with a string which is only in available to me and Ogone.
And with that problem the SHA-1 string built on my side is not the same than Ogone because URLs in the form are displayed without ?___SID=U : told you it won't be printed !
So first of all I don't know why Magento include it when I ask him in config to do not.
And secondly why can't I see the chars on the var_dump() or any echo ?
How can I debug this situation ? I guess there are some functions out there which could help me.
I patched the problem with another function to build the URL so my SHA-1 string is know ok and the module looks to work fine. My concerns are more focused about those hidden chars the strlen function AND hash function see but not echo or any other print function.
Thank you for your help, and excuse me for my bad english, not my mother language.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我也被这个问题困扰了。
请注意,这“适用于”打印整个字符串:
但是这个遗漏了
?___SID=U
部分:我也尝试打印字符的数字代码(十进制),但它似乎只是valid:
这是一个 PHP 错误吗?我以为这是一个编码/多字节/Unicode 问题,但事实证明这只是 Magento 模板系统的一个特性。
我尝试了这段代码:(注意:在 Magento 模板代码中!)
无论您相信与否,您都会得到以下结果:
因此,尽管 URL 是“错误的”,但 Magento 使用的机制“通过简单地执行我认为未记录的
str_replace
来隐藏”这些 URL 是更错误的。 (即使有记录,也没有人会想到这一点!)I also got hit by this problem.
Note that this "works" for printing out the whole string:
But this one leaves out the
?___SID=U
part:I also tried printing the numeric codes (in decimal) of the characters but it seems just valid:
Is this a PHP bug?I thought this was an encoding/multibyte/Unicode issue, but turned out this is just a Magento templating system peculiarity.
I tried this code: (note: in a Magento template code!)
and believe it or not, you'll get this:
So although the URLs are "wrong", the mechanism that Magento uses to "hide" those URLs are even more wrong by simply doing a
str_replace
that I believe is undocumented. (Even if it's documented, nobody would expect this!)这些“隐藏”字符可以是 Unicode 吗?你试过mb_strlen吗?
Could theses "hidden" chars be Unicode? Have you tried mb_strlen?
我们也遇到了同样的问题。
如果有人仍然遇到同样的问题,我找到了一个相当不错的解决方案。
最初,类似的内容包含在 Config.php 文件中:
如果用此替换它,则不会附加更多隐藏的 ?___SID 内容:
您应该对所有其他 get****Url() 函数执行相同的操作,问题就解决了。
We were hit by the same problem.
And I found a pretty decent solution for the problem in case somebody still encounter the same issue.
Originally, something like this was included in the Config.php file:
If you replace it by this, no more hidden ?___SID stuff will be attached:
You should do the same thing with all to other get****Url() functions, and the problem is solved.