@@ -109,6 +109,13 @@ pub struct PendingWindow<R: Runtime> {
109109 pub js_event_listeners : Arc < Mutex < HashMap < String , HashSet < u64 > > > > ,
110110}
111111
112+ fn validate_label ( label : & str ) {
113+ assert ! (
114+ label. chars( ) . all( char :: is_alphanumeric) ,
115+ "Window label must be alphanumeric"
116+ ) ;
117+ }
118+
112119impl < R : Runtime > PendingWindow < R > {
113120 /// Create a new [`PendingWindow`] with a label and starting url.
114121 pub fn new (
@@ -120,11 +127,13 @@ impl<R: Runtime> PendingWindow<R> {
120127 if let Some ( menu) = window_builder. get_menu ( ) {
121128 get_menu_ids ( & mut menu_ids, menu) ;
122129 }
130+ let label = label. into ( ) ;
131+ validate_label ( & label) ;
123132 Self {
124133 window_builder,
125134 webview_attributes,
126135 uri_scheme_protocols : Default :: default ( ) ,
127- label : label . into ( ) ,
136+ label,
128137 ipc_handler : None ,
129138 file_drop_handler : None ,
130139 url : "tauri://localhost" . to_string ( ) ,
@@ -144,11 +153,13 @@ impl<R: Runtime> PendingWindow<R> {
144153 if let Some ( menu) = window_builder. get_menu ( ) {
145154 get_menu_ids ( & mut menu_ids, menu) ;
146155 }
156+ let label = label. into ( ) ;
157+ validate_label ( & label) ;
147158 Self {
148159 window_builder,
149160 webview_attributes,
150161 uri_scheme_protocols : Default :: default ( ) ,
151- label : label . into ( ) ,
162+ label,
152163 ipc_handler : None ,
153164 file_drop_handler : None ,
154165 url : "tauri://localhost" . to_string ( ) ,
0 commit comments