mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-10-27 16:02:26 +00:00
Refactored `js/searchView.js` to use safe DOM APIs (`document.createElement`, `replaceChildren`, `textContent`) instead of `innerHTML`. This reduces the attack surface for XSS vulnerabilities. Updated `scripts/check-innerhtml.mjs` baseline. Verified with unit tests and a frontend verification script. Co-authored-by: PR0M3TH3AN <[email protected]>
49 lines
1.5 KiB
Python
49 lines
1.5 KiB
Python
from playwright.sync_api import sync_playwright
|
|
import os
|
|
|
|
def run(playwright):
|
|
browser = playwright.chromium.launch(headless=True)
|
|
context = browser.new_context()
|
|
|
|
# Inject localStorage to bypass disclaimer
|
|
page = context.new_page()
|
|
page.add_init_script("""
|
|
localStorage.setItem("hasSeenDisclaimer", "true");
|
|
""")
|
|
|
|
# Capture console logs
|
|
page.on("console", lambda msg: print(f"Browser console: {msg.text}"))
|
|
|
|
try:
|
|
# Navigate to the correct search URL format
|
|
page.goto("http://localhost:3000/#view=search&q=test", wait_until="networkidle")
|
|
print("Navigated to page")
|
|
|
|
# Wait for #searchTitle
|
|
print("Waiting for #searchTitle")
|
|
page.wait_for_selector("#searchTitle", timeout=10000)
|
|
print("Found #searchTitle")
|
|
|
|
# Wait for results or "no results" message
|
|
try:
|
|
# My refactor uses <p> with text content
|
|
page.wait_for_selector("#searchVideoList p", timeout=10000)
|
|
print("Found search results message")
|
|
except:
|
|
print("Timeout waiting for search results message")
|
|
|
|
# Take a screenshot
|
|
os.makedirs("verification", exist_ok=True)
|
|
page.screenshot(path="verification/search-results.png")
|
|
print("Screenshot saved")
|
|
|
|
except Exception as e:
|
|
print(f"Error: {e}")
|
|
page.screenshot(path="verification/error.png")
|
|
|
|
finally:
|
|
browser.close()
|
|
|
|
with sync_playwright() as playwright:
|
|
run(playwright)
|