Skip to content

Commit 2e29e53

Browse files
committed
docref shall either be NULL or a reference to a manual page without an
extension or an external reference starting with 'http://'.
1 parent 0019a84 commit 2e29e53

File tree

1 file changed

+35
-5
lines changed

1 file changed

+35
-5
lines changed

Diff for: main/main.c

+35-5
Original file line numberDiff line numberDiff line change
@@ -390,26 +390,56 @@ PHPAPI int php_printf(const char *format, ...)
390390
/* {{{ php_verror */
391391
PHPAPI void php_verror(const char *docref, const char *params, int type, const char *format, va_list args TSRMLS_DC)
392392
{
393-
char *buffer = NULL, *docref_buf = NULL, *function, *p;
393+
char *buffer = NULL, *docref_buf = NULL, *ref = NULL, *target = NULL;
394+
char *docref_target = "", *docref_root = "";
395+
char *function, *p;
394396

395397
vspprintf(&buffer, 0, format, args);
396398
if (buffer) {
397399
if (!docref) {
398400
function = get_active_function_name(TSRMLS_C);
399401
if (function) {
400-
spprintf(&docref_buf, 0, "function.%s%s", function, PG(docref_ext));
402+
spprintf(&docref_buf, 0, "function.%s", function);
401403
if (docref_buf) {
402404
while((p=strchr(docref_buf, '_'))!=NULL) *p = '-';
403405
docref = docref_buf;
404406
}
405407
}
406408
}
407409
if (docref) {
408-
if (PG(html_errors) && PG(docref_ext)) {
409-
php_error(type, "%s(%s) [<a href='%s%s'>%s</a>]: %s", get_active_function_name(TSRMLS_C), params, PG(docref_root), docref, docref, buffer);
410+
if (strncmp(docref, "http://", 7)) {
411+
docref_root = PG(docref_root);
412+
/* now check copy of extension */
413+
ref = estrdup(docref);
414+
if (ref) {
415+
if (docref_buf) {
416+
efree(docref_buf);
417+
}
418+
docref_buf = ref;
419+
p = strrchr(ref, '#');
420+
if (p) {
421+
target = estrdup(p);
422+
if (target) {
423+
docref_target = target;
424+
*p = '\0';
425+
}
426+
}
427+
if ((!p || target) && PG(docref_ext) && strlen(PG(docref_ext))) {
428+
spprintf(&docref_buf, 0, "%s%s", ref, PG(docref_ext));
429+
if (docref_buf) {
430+
efree(ref);
431+
docref = docref_buf;
432+
}
433+
}
434+
}
435+
}
436+
if (PG(html_errors)) {
437+
php_error(type, "%s(%s) [<a href='%s%s%s'>%s</a>]: %s", get_active_function_name(TSRMLS_C), params, docref_root, docref, docref, docref_target, buffer);
410438
} else {
411-
php_error(type, "%s(%s) [%s%s]: %s", get_active_function_name(TSRMLS_C), params, PG(docref_root), docref, buffer);
439+
php_error(type, "%s(%s) [%s%s%s]: %s", get_active_function_name(TSRMLS_C), params, docref_root, docref, docref_target, buffer);
412440
}
441+
if (target)
442+
efree(target);
413443
} else {
414444
docref = get_active_function_name(TSRMLS_C);
415445
if (!docref)

0 commit comments

Comments
 (0)