-
-
Notifications
You must be signed in to change notification settings - Fork 313
make issue number clickable-#3364 #4035
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
DonnieBLT
merged 7 commits into
OWASP-BLT:main
from
razzasid:feature/clickable-issue-number-3364
Apr 18, 2025
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
410dc9b
make issue number clickable-#3364
razzasid 7633439
remove duplicate code and fix dom handling
razzasid 9253373
Merge branch 'main' into feature/clickable-issue-number-3364
razzasid 4ee399c
Merge branch 'main' into feature/clickable-issue-number-3364
razzasid 415893f
Merge branch 'main' into feature/clickable-issue-number-3364
DonnieBLT e8c6a49
Merge branch 'main' into feature/clickable-issue-number-3364
DonnieBLT b1cbb4e
fix XSS vulnerability
razzasid File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -87,13 +87,18 @@ | |
| </span> | ||
| </nav> | ||
| <div class="flex flex-col gap-5 px-2"> | ||
| <div class="flex flex-col gap-2"> | ||
| <h2 class="text-xl sm:text-2xl md:text-3xl font-bold text-gray-900 leading-tight tracking-tight w-full break-words" | ||
| title="{{ object.description|escapejs }}">{{ object.description|escapejs }}</h2> | ||
| {% if object.markdown_description %} | ||
| <p class="text-base sm:text-lg text-gray-700 font-medium break-words" | ||
| id="bug_report">{{ object.markdown_description }}</p> | ||
| {% endif %} | ||
| <div class="flex flex-col gap-5 px-2"> | ||
| <div class="flex flex-col gap-2"> | ||
| <h2 class="text-xl sm:text-2xl md:text-3xl font-bold text-gray-900 leading-tight tracking-tight w-full break-words issue-description" | ||
| title="{{ object.description|escapejs }}">{{ object.description|escapejs }}</h2> | ||
| {% if object.markdown_description %} | ||
| <p class="text-base sm:text-lg text-gray-700 font-medium break-words" | ||
| id="bug_report" | ||
| data-markdown="{{ object.markdown_description|escapejs }}"> | ||
| <!-- This content will be replaced by rendered markdown --> | ||
| </p> | ||
| {% endif %} | ||
| </div> | ||
| </div> | ||
| <a href="{{ object.url }}" | ||
| title="{{ object.url }}" | ||
|
|
@@ -240,15 +245,49 @@ | |
| likeModal.style.cssText = "display:block !important;"; | ||
| } | ||
| </script> | ||
| <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/purify.min.js"></script> | ||
| <script> | ||
| if (window.markdownit) { | ||
| document.addEventListener('DOMContentLoaded', () => { | ||
|
|
||
| const bugReportElement = document.getElementById('bug_report'); | ||
|
|
||
| if (bugReportElement && window.markdownit) { | ||
| const md = new window.markdownit(); | ||
| const markdownContent = `{{ object.markdown_description|escapejs }}`; | ||
| const renderedHtml = md.render(markdownContent); | ||
| $("#bug_report").html(renderedHtml); | ||
| } else { | ||
| console.error('MarkdownIt library failed to load.'); | ||
| const markdownContent = bugReportElement.getAttribute('data-markdown') || bugReportElement.textContent; | ||
|
|
||
| // First render the markdown | ||
| let renderedHtml = md.render(markdownContent); | ||
|
|
||
| // Then transform issue references to clickable links | ||
| renderedHtml = renderedHtml.replace( | ||
| /#(\d+)/g, | ||
| '<a href="/issue/$1" class="text-[#e74c3c] hover:text-[#e74c3c]/80 font-medium">#$1</a>' | ||
| ); | ||
|
|
||
| // Update the content | ||
| bugReportElement.innerHTML = DOMPurify.sanitize(renderedHtml, { | ||
| ALLOWED_TAGS: ['a', 'p', 'strong', 'em', 'ul', 'li', 'code', 'pre', 'blockquote'], | ||
| ALLOWED_ATTR: ['href', 'class'] | ||
| }); | ||
| } | ||
|
|
||
| // Also process the issue title/description for issue references | ||
| const issueDescriptionElement = document.querySelector('.issue-description'); | ||
| if (issueDescriptionElement) { | ||
| const originalText = issueDescriptionElement.textContent; | ||
|
|
||
| // Transform issue references to clickable links | ||
| const transformedText = originalText.replace( | ||
| /#(\d+)/g, | ||
| '<a href="/issue/$1" class="text-[#e74c3c] hover:text-[#e74c3c]/80 font-medium">#$1</a>' | ||
| ); | ||
|
|
||
| issueDescriptionElement.innerHTML = DOMPurify.sanitize(transformedText, { | ||
| ALLOWED_TAGS: ['a'], | ||
| ALLOWED_ATTR: ['href', 'class'] | ||
| }); | ||
| } | ||
| }); | ||
| </script> | ||
| <script src="https://cdn.jsdelivr.net/npm/@splidejs/[email protected]/dist/js/splide.min.js" | ||
| integrity="sha256-FZsW7H2V5X9TGinSjjwYJ419Xka27I8XPDmWryGlWtw=" | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.