Skip to content

Commit 667ae82

Browse files
committed
use noopener for window.open (#4933)
1 parent 69605f7 commit 667ae82

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

reflex/.templates/web/utils/state.js

+18-18
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ export const applyEvent = async (event, socket) => {
179179
// Handle special events
180180
if (event.name == "_redirect") {
181181
if (event.payload.external) {
182-
window.open(event.payload.path, "_blank");
182+
window.open(event.payload.path, "_blank", "noopener");
183183
} else if (event.payload.replace) {
184184
Router.replace(event.payload.path);
185185
} else {
@@ -227,8 +227,8 @@ export const applyEvent = async (event, socket) => {
227227
a.href = eval?.(
228228
event.payload.url.replace(
229229
"getBackendURL(env.UPLOAD)",
230-
`"${getBackendURL(env.UPLOAD)}"`,
231-
),
230+
`"${getBackendURL(env.UPLOAD)}"`
231+
)
232232
);
233233
}
234234
a.download = event.payload.filename;
@@ -341,7 +341,7 @@ export const applyRestEvent = async (event, socket) => {
341341
event.payload.files,
342342
event.payload.upload_id,
343343
event.payload.on_upload_progress,
344-
socket,
344+
socket
345345
);
346346
return false;
347347
}
@@ -408,7 +408,7 @@ export const connect = async (
408408
dispatch,
409409
transports,
410410
setConnectErrors,
411-
client_storage = {},
411+
client_storage = {}
412412
) => {
413413
// Get backend URL object from the endpoint.
414414
const endpoint = getBackendURL(EVENTURL);
@@ -499,7 +499,7 @@ export const uploadFiles = async (
499499
files,
500500
upload_id,
501501
on_upload_progress,
502-
socket,
502+
socket
503503
) => {
504504
// return if there's no file to upload
505505
if (files === undefined || files.length === 0) {
@@ -604,7 +604,7 @@ export const Event = (
604604
name,
605605
payload = {},
606606
event_actions = {},
607-
handler = null,
607+
handler = null
608608
) => {
609609
return { name, payload, handler, event_actions };
610610
};
@@ -631,7 +631,7 @@ export const hydrateClientStorage = (client_storage) => {
631631
for (const state_key in client_storage.local_storage) {
632632
const options = client_storage.local_storage[state_key];
633633
const local_storage_value = localStorage.getItem(
634-
options.name || state_key,
634+
options.name || state_key
635635
);
636636
if (local_storage_value !== null) {
637637
client_storage_values[state_key] = local_storage_value;
@@ -642,7 +642,7 @@ export const hydrateClientStorage = (client_storage) => {
642642
for (const state_key in client_storage.session_storage) {
643643
const session_options = client_storage.session_storage[state_key];
644644
const session_storage_value = sessionStorage.getItem(
645-
session_options.name || state_key,
645+
session_options.name || state_key
646646
);
647647
if (session_storage_value != null) {
648648
client_storage_values[state_key] = session_storage_value;
@@ -667,7 +667,7 @@ export const hydrateClientStorage = (client_storage) => {
667667
const applyClientStorageDelta = (client_storage, delta) => {
668668
// find the main state and check for is_hydrated
669669
const unqualified_states = Object.keys(delta).filter(
670-
(key) => key.split(".").length === 1,
670+
(key) => key.split(".").length === 1
671671
);
672672
if (unqualified_states.length === 1) {
673673
const main_state = delta[unqualified_states[0]];
@@ -701,7 +701,7 @@ const applyClientStorageDelta = (client_storage, delta) => {
701701
const session_options = client_storage.session_storage[state_key];
702702
sessionStorage.setItem(
703703
session_options.name || state_key,
704-
delta[substate][key],
704+
delta[substate][key]
705705
);
706706
}
707707
}
@@ -721,7 +721,7 @@ const applyClientStorageDelta = (client_storage, delta) => {
721721
export const useEventLoop = (
722722
dispatch,
723723
initial_events = () => [],
724-
client_storage = {},
724+
client_storage = {}
725725
) => {
726726
const socket = useRef(null);
727727
const router = useRouter();
@@ -735,7 +735,7 @@ export const useEventLoop = (
735735

736736
event_actions = events.reduce(
737737
(acc, e) => ({ ...acc, ...e.event_actions }),
738-
event_actions ?? {},
738+
event_actions ?? {}
739739
);
740740

741741
const _e = args.filter((o) => o?.preventDefault !== undefined)[0];
@@ -763,7 +763,7 @@ export const useEventLoop = (
763763
debounce(
764764
combined_name,
765765
() => queueEvents(events, socket),
766-
event_actions.debounce,
766+
event_actions.debounce
767767
);
768768
} else {
769769
queueEvents(events, socket);
@@ -782,7 +782,7 @@ export const useEventLoop = (
782782
query,
783783
asPath,
784784
}))(router),
785-
})),
785+
}))
786786
);
787787
sentHydrate.current = true;
788788
}
@@ -828,7 +828,7 @@ export const useEventLoop = (
828828
dispatch,
829829
["websocket"],
830830
setConnectErrors,
831-
client_storage,
831+
client_storage
832832
);
833833
}
834834
}
@@ -876,7 +876,7 @@ export const useEventLoop = (
876876
vars[storage_to_state_map[e.key]] = e.newValue;
877877
const event = Event(
878878
`${state_name}.reflex___state____update_vars_internal_state.update_vars_internal`,
879-
{ vars: vars },
879+
{ vars: vars }
880880
);
881881
addEvents([event], e);
882882
}
@@ -969,7 +969,7 @@ export const getRefValues = (refs) => {
969969
return refs.map((ref) =>
970970
ref.current
971971
? ref.current.value || ref.current.getAttribute("aria-valuenow")
972-
: null,
972+
: null
973973
);
974974
};
975975

0 commit comments

Comments
 (0)