Skip to content

Commit

Permalink
Merge branch 'xdebug_2_3'
Browse files Browse the repository at this point in the history
  • Loading branch information
derickr committed Jun 13, 2015
2 parents 2962049 + c6d11b0 commit 884fe05
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 1 deletion.
23 changes: 23 additions & 0 deletions tests/bug01130.phpt
@@ -0,0 +1,23 @@
--TEST--
Test for bug #1130: PHP documentation links to local manual reference are broken at title description
--INI--
docref_root=http://www.php.net/
docref_ext=.php
html_errors=1
xdebug.default_enable=1
xdebug.file_link_format=
xdebug.collect_params=0
--FILE--
<?php
html_entity_decode("", 0, "l<r");
?>
--EXPECTF--
<br />
<font size='1'><table class='xdebug-error xe-warning' dir='ltr' border='1' cellspacing='0' cellpadding='1'>
<tr><th align='left' bgcolor='#f57900' colspan="5"><span style='background-color: #cc0000; color: #fce94f; font-size: x-large;'>( ! )</span> Warning: html_entity_decode() [<a href='http://www.php.net/function.html-entity-decode.php'>function.html-entity-decode.php</a>: charset `l&amp;lt;r' not supported, assuming utf-8 in %sbug01130.php on line <i>2</i></th></tr>
<tr><th align='left' bgcolor='#e9b96e' colspan='5'>Call Stack</th></tr>
<tr><th align='center' bgcolor='#eeeeec'>#</th><th align='left' bgcolor='#eeeeec'>Time</th><th align='left' bgcolor='#eeeeec'>Memory</th><th align='left' bgcolor='#eeeeec'>Function</th><th align='left' bgcolor='#eeeeec'>Location</th></tr>
<tr><td bgcolor='#eeeeec' align='center'>1</td><td bgcolor='#eeeeec' align='center'>%f</td><td bgcolor='#eeeeec' align='right'>%d</td><td bgcolor='#eeeeec'>{main}( )</td><td title='%sbug01130.php' bgcolor='#eeeeec'>.../bug01130.php<b>:</b>0</td></tr>
<tr><td bgcolor='#eeeeec' align='center'>2</td><td bgcolor='#eeeeec' align='center'>%f</td><td bgcolor='#eeeeec' align='right'>%d</td><td bgcolor='#eeeeec'><a href='http://www.php.net/function.html-entity-decode.php' target='_new'>html_entity_decode</a>
( )</td><td title='%sbug01130.php' bgcolor='#eeeeec'>.../bug01130.php<b>:</b>2</td></tr>
</table></font>
29 changes: 28 additions & 1 deletion xdebug_stack.c
Expand Up @@ -26,6 +26,7 @@
#include "xdebug_superglobals.h"
#include "xdebug_var.h"
#include "ext/standard/html.h"
#include "ext/standard/php_smart_str.h"

#include "main/php_ini.h"

Expand Down Expand Up @@ -232,7 +233,33 @@ void xdebug_append_error_description(xdebug_str *str, int html, const char *erro
size_t newlen;

if (html) {
escaped = php_escape_html_entities((unsigned char *) buffer, strlen(buffer), &newlen, 0, 0, NULL TSRMLS_CC);
char *tmp;
char *first_closing = strchr(buffer, ']');

/* We do need to escape HTML entities here, as HTML chars could be in
* the error message. However, PHP in some circumstances also adds an
* HTML link to a manual page. That bit, we don't need to escape. So
* this bit of code finds the portion that doesn't need escaping, adds
* it to a tmp string, and then adds an HTML escaped string for the
* rest of the original buffer. */
if (first_closing && strstr(buffer, "() [<a href=") != NULL) {
smart_str special_escaped = {0};

*first_closing = '\0';
first_closing++;
smart_str_appends(&special_escaped, buffer);

tmp = php_escape_html_entities((unsigned char *) first_closing, strlen(first_closing), &newlen, 0, 0, NULL TSRMLS_CC);
smart_str_appends(&special_escaped, tmp);
STR_FREE(tmp);

smart_str_0(&special_escaped);

escaped = estrdup(special_escaped.c);
smart_str_free(&special_escaped);
} else {
escaped = php_escape_html_entities((unsigned char *) buffer, strlen(buffer), &newlen, 0, 0, NULL TSRMLS_CC);
}
} else {
escaped = estrdup(buffer);
}
Expand Down

0 comments on commit 884fe05

Please sign in to comment.