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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
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-2019 The PHP Group
All rights reserved.
Last updated: Thu Dec 12 18:01:24 2019 UTC