php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #61979 LibXMLError Object property 'message' contains LF at the end of string
Submitted: 2012-05-09 09:23 UTC Modified: 2018-03-14 23:10 UTC
From: piotr at smartwebstudio dot cz Assigned:
Status: Open Package: *XML functions
PHP Version: 5.3.13 OS: Windows Vista 32bit
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
9 + 14 = ?
Subscribe to this entry?

 
 [2012-05-09 09:23 UTC] piotr at smartwebstudio dot cz
Description:
------------
---
From manual page: http://www.php.net/manual/pl/function.libxml-get-last-error.php
---
Tested on PHP 5.3.0, Apache 2.2.11

LibXMLError Object property 'message' contains LF (ASCII 10) at the end of 
string.
Makes it harder to compare error messages that should be ignored or assign 
translation strings.

Test script:
---------------
libxml_use_internal_errors(true);
// Define xml string that contains known error
$vcard = new SimpleXMLElement("<vCard xmlns='vcard-temp'></vcard>");

// Retrieve last LibXMLError object
$last_error = libxml_get_last_error();

// Should be true
var_dump($last_error->message == "xmlns: URI vcard-temp is not absolute");

// Workaround
var_dump(trim($last_error->message) == "xmlns: URI vcard-temp is not absolute");

Expected result:
----------------
bool(true)
bool(true)

Actual result:
--------------
bool(false)
bool(true)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-06-13 18:14 UTC] cmb@php.net
In my opinion this is not a bug, as I understand the error message
as "human-readable informative error message"[1]. And I would
rather check for the error code to avoid issues due to libxml
changing the error messages or localization issues.

[1] <http://www.xmlsoft.org/html/libxml-xmlerror.html#xmlError>
 [2018-03-14 23:10 UTC] cmb@php.net
-Package: XML related +Package: *XML functions
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Mon Nov 18 23:01:35 2019 UTC