php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #75971 strip_tags removes incorrect part of string
Submitted: 2018-02-16 18:10 UTC Modified: 2018-02-16 18:25 UTC
From: barahtyan at gmail dot com Assigned:
Status: Not a bug Package: Strings related
PHP Version: 7.1.14 OS: Ubuntu 16.04
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: barahtyan at gmail dot com
New email:
PHP Version: OS:

 

 [2018-02-16 18:10 UTC] barahtyan at gmail dot com
Description:
------------
echo strip_tags('test <------ Test');

I expect to receive the same "test <------ Test", since there is not tags.

Unfortunately, PHP removes all string after <------.

I пуе "test " without <------ Test.

Test script:
---------------
echo strip_tags('test <------ Test');

Expected result:
----------------
test <------ Test

Actual result:
--------------
test 

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-02-16 18:25 UTC] requinix@php.net
-Status: Open +Status: Not a bug
 [2018-02-16 18:25 UTC] requinix@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

> Warning
> Because strip_tags() does not actually validate the HTML, partial or broken tags can result in the removal of more
> text/data than expected.
 [2018-02-16 18:25 UTC] subjective@php.net
strip_tags() is a pretty aggressive string function, not a "real" HTML/XML parser. So this should be the expected behavior:

From the manual:

Warning: Because strip_tags() does not actually validate the HTML, partial or broken tags can result in the removal of more text/data than expected.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Apr 24 08:01:29 2024 UTC