| 36 | 36 | $this->renderBreadcrumbs(); |
| 37 | 37 | |
| 38 | // Fix 1: Redact email address |
| 39 | $author = $headers['author'] ?? 'Unknown'; |
| 40 | $author = preg_replace('/<[^>]+>/', '<email>', $author); |
| 41 | |
| 38 | 42 | echo '<div class="commit-details">'; |
| 39 | 43 | echo '<div class="commit-header">'; |
| 40 | 44 | echo '<h1 class="commit-title">' . htmlspecialchars(trim($msg)) . '</h1>'; |
| 41 | 45 | echo '<div class="commit-info">'; |
| 42 | | echo '<div class="commit-info-row"><span class="commit-info-label">Author</span><span class="commit-author">' . htmlspecialchars($headers['author'] ?? 'Unknown') . '</span></div>'; |
| 46 | echo '<div class="commit-info-row"><span class="commit-info-label">Author</span><span class="commit-author">' . htmlspecialchars($author) . '</span></div>'; |
| 43 | 47 | echo '<div class="commit-info-row"><span class="commit-info-label">Commit</span><span class="commit-info-value">' . $this->hash . '</span></div>'; |
| 48 | |
| 44 | 49 | if (isset($headers['parent'])) { |
| 45 | | $repoUrl = '?repo=' . urlencode($this->currentRepo['safe_name']); |
| 50 | // Fix 2: Use '&' instead of '?' because parameters (action & hash) already exist |
| 51 | $repoUrl = '&repo=' . urlencode($this->currentRepo['safe_name']); |
| 46 | 52 | echo '<div class="commit-info-row"><span class="commit-info-label">Parent</span><span class="commit-info-value">'; |
| 47 | 53 | echo '<a href="?action=commit&hash=' . $headers['parent'] . $repoUrl . '" class="parent-link">' . substr($headers['parent'], 0, 7) . '</a>'; |
| ... |
| 79 | 85 | echo '<div class="diff-binary">Binary files differ</div>'; |
| 80 | 86 | } else { |
| 81 | | echo '<div class="diff-content">'; |
| 82 | | echo '<table><tbody>'; |
| 87 | echo '<div class="diff-content">'; |
| 88 | echo '<table><tbody>'; |
| 83 | 89 | |
| 84 | | foreach ($change['hunks'] as $line) { |
| 85 | | if (isset($line['t']) && $line['t'] === 'gap') { |
| 86 | | echo '<tr class="diff-gap"><td colspan="3">...</td></tr>'; |
| 87 | | continue; |
| 88 | | } |
| 90 | foreach ($change['hunks'] as $line) { |
| 91 | if (isset($line['t']) && $line['t'] === 'gap') { |
| 92 | echo '<tr class="diff-gap"><td colspan="3">...</td></tr>'; |
| 93 | continue; |
| 94 | } |
| 89 | 95 | |
| 90 | | $class = 'diff-ctx'; |
| 91 | | $char = ' '; |
| 92 | | if ($line['t'] === '+') { $class = 'diff-add'; $char = '+'; } |
| 93 | | if ($line['t'] === '-') { $class = 'diff-del'; $char = '-'; } |
| 96 | $class = 'diff-ctx'; |
| 97 | $char = ' '; |
| 98 | if ($line['t'] === '+') { $class = 'diff-add'; $char = '+'; } |
| 99 | if ($line['t'] === '-') { $class = 'diff-del'; $char = '-'; } |
| 94 | 100 | |
| 95 | | echo '<tr class="' . $class . '">'; |
| 96 | | echo '<td class="diff-num" data-num="' . $line['no'] . '"></td>'; |
| 97 | | echo '<td class="diff-num" data-num="' . $line['nn'] . '"></td>'; |
| 98 | | echo '<td class="diff-code"><span class="diff-marker">' . $char . '</span>' . htmlspecialchars($line['l']) . '</td>'; |
| 99 | | echo '</tr>'; |
| 100 | | } |
| 101 | | echo '</tbody></table>'; |
| 102 | | echo '</div>'; |
| 101 | echo '<tr class="' . $class . '">'; |
| 102 | echo '<td class="diff-num" data-num="' . $line['no'] . '"></td>'; |
| 103 | echo '<td class="diff-num" data-num="' . $line['nn'] . '"></td>'; |
| 104 | echo '<td class="diff-code"><span class="diff-marker">' . $char . '</span>' . htmlspecialchars($line['l']) . '</td>'; |
| 105 | echo '</tr>'; |
| 106 | } |
| 107 | |
| 108 | echo '</tbody></table>'; |
| 109 | echo '</div>'; |
| 103 | 110 | } |
| 104 | 111 | echo '</div>'; |
| 105 | 112 | } |
| 106 | 113 | |
| 107 | 114 | private function renderBreadcrumbs() { |
| 108 | | $repoUrl = '?repo=' . urlencode( $this->currentRepo['safe_name'] ); |
| 115 | $safeName = urlencode($this->currentRepo['safe_name']); |
| 116 | |
| 109 | 117 | $crumbs = [ |
| 110 | 118 | '<a href="?">Repositories</a>', |
| 111 | | '<a href="' . $repoUrl . '">' . htmlspecialchars($this->currentRepo['name']) . '</a>', |
| 112 | | '<a href="?action=commits' . $repoUrl . '">Commits</a>', |
| 119 | '<a href="?repo=' . $safeName . '">' . htmlspecialchars($this->currentRepo['name']) . '</a>', |
| 120 | // Fix 3: Use '&' separator for the repo parameter |
| 121 | '<a href="?action=commits&repo=' . $safeName . '">Commits</a>', |
| 113 | 122 | substr($this->hash, 0, 7) |
| 114 | 123 | ]; |