Correctly handle non-numeric exception codes in core.functions.php
authorTim Düsterhus <duesterhus@woltlab.com>
Thu, 2 Jul 2020 13:32:19 +0000 (15:32 +0200)
committerTim Düsterhus <duesterhus@woltlab.com>
Thu, 2 Jul 2020 13:32:39 +0000 (15:32 +0200)
Database exceptions use the SQLSTATE as the error code. SQLSTATEs can
contains letters.

wcfsetup/install/files/lib/core.functions.php

index 6e53aacb03669a823c0422fda7d25fe752e61823..e125ce4458a92bf28e12fc192af55c96da71f653 100644 (file)
@@ -141,7 +141,7 @@ namespace wcf\functions\exception {
                        $message .= "======\n".
                        'Error Class: '.get_class($prev)."\n".
                        'Error Message: '.$stripNewlines($prev->getMessage())."\n".
-                       'Error Code: '.intval($prev->getCode())."\n".
+                       'Error Code: '.$stripNewlines($prev->getCode())."\n".
                        'File: '.$stripNewlines($prev->getFile()).' ('.$prev->getLine().')'."\n".
                        'Extra Information: '.($prev instanceof IExtraInformationException ? base64_encode(serialize($prev->getExtraInformation())) : '-')."\n".
                        'Stack Trace: '.json_encode(array_map(function ($item) {
@@ -499,7 +499,7 @@ EXPLANATION;
                                                        <?php if ($e->getCode()) { ?>
                                                                <li>
                                                                        <p class="exceptionFieldTitle">Error Code<span class="exceptionColon">:</span></p>
-                                                                       <p class="exceptionFieldValue"><?php echo intval($e->getCode()); ?></p>
+                                                                       <p class="exceptionFieldValue"><?php echo StringUtil::encodeHTML($e->getCode()); ?></p>
                                                                </li>
                                                        <?php } ?>
                                                        <li>