[object Object]

← back to Ad Signals Rolodex

Code-quality fixes to build-rolodex.py

ef77ba01d3c02df7da9062ffdea43cc52cd9fca7 · 2026-05-18 17:38:27 -0700 · Steve

- Add rel=noopener noreferrer to external links (prevent reverse tabnabbing)
- Specify encoding=utf-8 on CSV reads and HTML write (fix non-ASCII business names)
- Fix docstring: 5 cohorts, not 4

Files touched

Diff

commit ef77ba01d3c02df7da9062ffdea43cc52cd9fca7
Author: Steve <steve@designerwallcoverings.com>
Date:   Mon May 18 17:38:27 2026 -0700

    Code-quality fixes to build-rolodex.py
    
    - Add rel=noopener noreferrer to external links (prevent reverse tabnabbing)
    - Specify encoding=utf-8 on CSV reads and HTML write (fix non-ASCII business names)
    - Fix docstring: 5 cohorts, not 4
---
 build-rolodex.py | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/build-rolodex.py b/build-rolodex.py
index a89daa1..aeeb542 100644
--- a/build-rolodex.py
+++ b/build-rolodex.py
@@ -1,5 +1,5 @@
 #!/usr/bin/env python3
-"""Unified ad-signals rolodex — combines all 4 cohorts into one HTML viewer.
+"""Unified ad-signals rolodex — combines all 5 cohorts into one HTML viewer.
 ventura-corridor + lawyer + animals + doctor + lacountyeats. No LLM.
 """
 import csv, json, os, sys
@@ -75,7 +75,7 @@ for src in SOURCES:
         print(f'  ! missing: {src["csv"]}', file=sys.stderr)
         project_counts[src['project']] = 0
         continue
-    with open(src['csv']) as f:
+    with open(src['csv'], encoding='utf-8') as f:
         rows = list(csv.DictReader(f))
     project_counts[src['project']] = len(rows)
     for r in rows:
@@ -192,14 +192,14 @@ function render(){{
     <td>${{eh(r.city)}}, ${{eh(r.state)}}</td>
     <td>${{r.paid_pixels}}</td>
     <td><span class="${{tierClass(r.tier)}}">${{r.tier.replace(/_/g,' ')}}</span></td>
-    <td>${{r.website?`<a href="${{eh(r.website)}}" target="_blank">${{eh(r.website.replace(/^https?:\\/\\//,'').slice(0,40))}}</a>`:''}}</td>
+    <td>${{r.website?`<a href="${{eh(r.website)}}" target="_blank" rel="noopener noreferrer">${{eh(r.website.replace(/^https?:\\/\\//,'').slice(0,40))}}</a>`:''}}</td>
   </tr>`).join('');
   document.getElementById('visible-count').textContent=`${{f.length}} of ${{DATA.length}}`;
 }}
 render();
 </script></body></html>"""
 
-with open(OUT, 'w') as f:
+with open(OUT, 'w', encoding='utf-8') as f:
     f.write(HTML)
 
 print(f'Wrote {OUT} · {len(HTML):,} bytes · {total} businesses across {sum(1 for v in project_counts.values() if v > 0)} projects')

← a3c0796 snapshot: 1 file(s) changed, ~1 modified  ·  back to Ad Signals Rolodex  ·  Regenerate rolodex.html with noopener links and utf-8 output 95e3e0b →