最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

When use the Conversion Filters convert.base64-encode between php:filter and data:, data loss may occur in versions up to PHP7 -

programmeradmin2浏览0评论
<?php

$data1 = file_get_contents("php://filter/convert.base64-encode/resource=data://text/plain,111111111");
$data2 = file_get_contents("php://filter/convert.base64-encode/resource=data://text/plain,11111111111");

echo $data1."\n";
echo $data2."\n";


echo ($data1 === $data2) ? "Same output" : "Different output";

We can see that the streams of "data://" is different,$data1 is nine '1',$data1 is eleven '1'.

In the PHP8,the result is "Different output",but up to php7,it will output "Same output".

Why their results are different,is it a bug?I couldn't find ang information about this on the web.

This situation always occurs when the input length is a multiple of 3.

$data1 = file_get_contents("php://filter/convert.base64-encode/resource=data://text/plain,111111111");
$data2 = file_get_contents("php://filter/convert.base64-encode/resource=data://text/plain,1111111111");
$data3 = file_get_contents("php://filter/convert.base64-encode/resource=data://text/plain,11111111111");
echo $data1."\n";
echo $data2."\n";
echo $data3."\n";

In PHP7 output:

MTExMTExMTEx
MTExMTExMTEx
MTExMTExMTEx

Sorry if you don't understand because my english.

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论