0
0
mirror of https://github.com/ezyang/htmlpurifier.git synced 2024-12-22 16:31:53 +00:00

Remove unnecessary reference assigment (#301)

* Remove unnecessary reference assigment

Proposed code is PHP5 and PHP7 compatible. PHP5 interpreted `$e->$type[$attr]` as `$e->{$type[$attr]}`, but the expected behavior based on workaround is consistent with PHP7 interpretation: `($e->$type)[$attr]`. By using curly braces `{$e->$type}[$attr]` there is a forced interpretation order working for both versions.
Details can be found on https://www.php.net/manual/en/migration70.incompatible.php (section "Changes to the handling of indirect variables, properties, and methods")

* Fix syntax

Use correct syntax for indirect variable evaluation order change.
This commit is contained in:
Arkadiusz Biczewski 2021-09-07 20:16:55 +02:00 committed by GitHub
parent c97bb93223
commit 996eaf4331
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -146,10 +146,7 @@ class HTMLPurifier_HTMLModule_Tidy extends HTMLPurifier_HTMLModule
$type = "info_$type"; $type = "info_$type";
$e = $this; $e = $this;
} }
// PHP does some weird parsing when I do $e->{$type}[$attr] = $fix;
// $e->$type[$attr], so I have to assign a ref.
$f =& $e->$type;
$f[$attr] = $fix;
break; break;
case 'tag_transform': case 'tag_transform':
$this->info_tag_transform[$params['element']] = $fix; $this->info_tag_transform[$params['element']] = $fix;