File tree Expand file tree Collapse file tree 2 files changed +17
-2
lines changed
components/dash-core-components/src/components
tests/integration/security Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -46,7 +46,9 @@ const Link = props => {
46
46
refresh,
47
47
setProps,
48
48
} = props ;
49
- const sanitizedUrl = useMemo ( ( ) => sanitizeUrl ( href ) , [ href ] ) ;
49
+ const sanitizedUrl = useMemo ( ( ) => {
50
+ return href ? sanitizeUrl ( href ) : undefined ;
51
+ } , [ href ] ) ;
50
52
51
53
const updateLocation = e => {
52
54
const hasModifiers = e . metaKey || e . shiftKey || e . altKey || e . ctrlKey ;
@@ -70,7 +72,7 @@ const Link = props => {
70
72
} ;
71
73
72
74
useEffect ( ( ) => {
73
- if ( sanitizedUrl !== href ) {
75
+ if ( sanitizedUrl && sanitizedUrl !== href ) {
74
76
setProps ( {
75
77
_dash_error : new Error ( `Dangerous link detected:: ${ href } ` ) ,
76
78
} ) ;
Original file line number Diff line number Diff line change @@ -45,3 +45,16 @@ def test_xss001_banned_protocols(dash_duo):
45
45
assert (
46
46
element .get_attribute (prop ) == "about:blank"
47
47
), f"Failed prop: { element_id } .{ prop } "
48
+
49
+
50
+ def test_xss002_blank_href (dash_duo ):
51
+ app = Dash ()
52
+
53
+ app .layout = html .Div (dcc .Link ("dcc-link" , href = "" , id = "dcc-link-no-href" ))
54
+
55
+ dash_duo .start_server (app )
56
+
57
+ element = dash_duo .find_element ("#dcc-link-no-href" )
58
+ assert element .get_attribute ("href" ) is None
59
+
60
+ assert dash_duo .get_logs () == []
You can’t perform that action at this time.
0 commit comments