File tree Expand file tree Collapse file tree 3 files changed +21
-2
lines changed
components/dash-core-components/src/components
tests/integration/security Expand file tree Collapse file tree 3 files changed +21
-2
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,10 @@ This project adheres to [Semantic Versioning](https://semver.org/).
44
55## [UNRELEASED]
66
7+ ## Fixed
8+
9+ - [#2756](https://github.com/plotly/dash/pull/2756) Prevent false dangerous link warning. Fixes [#2743](https://github.com/plotly/dash/issues/2743)
10+
711## Changed
812
913- [#2734](https://github.com/plotly/dash/pull/2734) Configure CI for Python 3.10 [#1863](https://github.com/plotly/dash/issues/1863)
Original file line number Diff line number Diff line change @@ -46,7 +46,9 @@ const Link = props => {
4646 refresh,
4747 setProps,
4848 } = props ;
49- const sanitizedUrl = useMemo ( ( ) => sanitizeUrl ( href ) , [ href ] ) ;
49+ const sanitizedUrl = useMemo ( ( ) => {
50+ return href ? sanitizeUrl ( href ) : undefined ;
51+ } , [ href ] ) ;
5052
5153 const updateLocation = e => {
5254 const hasModifiers = e . metaKey || e . shiftKey || e . altKey || e . ctrlKey ;
@@ -70,7 +72,7 @@ const Link = props => {
7072 } ;
7173
7274 useEffect ( ( ) => {
73- if ( sanitizedUrl !== href ) {
75+ if ( sanitizedUrl && sanitizedUrl !== href ) {
7476 setProps ( {
7577 _dash_error : new Error ( `Dangerous link detected:: ${ href } ` ) ,
7678 } ) ;
Original file line number Diff line number Diff line change @@ -45,3 +45,16 @@ def test_xss001_banned_protocols(dash_duo):
4545 assert (
4646 element .get_attribute (prop ) == "about:blank"
4747 ), 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