File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed
Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -124,10 +124,16 @@ function escapeHTML(value) {
124124function safeHref ( href ) {
125125 const s = String ( href || "" ) . trim ( ) ;
126126 const lower = s . toLowerCase ( ) ;
127- if ( ! s || lower . startsWith ( "javascript:" ) || lower . startsWith ( "data:" ) || lower . startsWith ( "vbscript:" ) ) {
128- return "#" ;
127+ // Allow relative URLs (path, hash, or query only)
128+ if ( s . startsWith ( "/" ) || s . startsWith ( "#" ) || s . startsWith ( "?" ) ) {
129+ return s ;
129130 }
130- return s ;
131+ // Allow only http and https absolute URLs
132+ if ( lower . startsWith ( "http://" ) || lower . startsWith ( "https://" ) ) {
133+ return s ;
134+ }
135+ // Fallback for disallowed or empty URLs
136+ return "#" ;
131137}
132138
133139function queryResultLink ( link , query , url ) {
You can’t perform that action at this time.
0 commit comments