File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -23,6 +23,14 @@ const chat = require('./chat').chat;
2323import html10n from './vendors/html10n' ;
2424let myUserInfo = { } ;
2525
26+ const decodePadSegment = ( segment : string ) : string => {
27+ try {
28+ return decodeURIComponent ( segment ) ;
29+ } catch {
30+ return segment ;
31+ }
32+ } ;
33+
2634let colorPickerOpen = false ;
2735let colorPickerSetup = false ;
2836
@@ -557,7 +565,7 @@ const paduserlist = (() => {
557565 if ( localStorage . getItem ( 'recentPads' ) != null ) {
558566 const recentPadsList = JSON . parse ( localStorage . getItem ( 'recentPads' ) ) ;
559567 const pathSegments = window . location . pathname . split ( '/' ) ;
560- const padName = pathSegments [ pathSegments . length - 1 ] ;
568+ const padName = decodePadSegment ( pathSegments [ pathSegments . length - 1 ] ) ;
561569 const existingPad = recentPadsList . find ( ( pad ) => pad . name === padName ) ;
562570 if ( existingPad ) {
563571 existingPad . members = online ;
Original file line number Diff line number Diff line change 11'use strict' ;
22
3+ const decodePadName = ( name ) => {
4+ try {
5+ return decodeURIComponent ( name ) ;
6+ } catch {
7+ return name ;
8+ }
9+ } ;
10+
311window . addEventListener ( 'pageshow' , ( event ) => {
412 if ( event . persisted ) {
513 if ( document . readyState === 'complete' || document . readyState === 'interactive' ) {
@@ -37,6 +45,13 @@ window.customStart = () => {
3745 recentPadListData = JSON . parse ( recentPadsFromLocalStorage ) ;
3846 }
3947
48+ // Normalize older entries that stored encoded names (e.g. Test%2F123).
49+ recentPadListData = recentPadListData . map ( ( pad ) => ( {
50+ ...pad ,
51+ name : decodePadName ( String ( pad . name ?? '' ) ) ,
52+ } ) ) ;
53+ localStorage . setItem ( 'recentPads' , JSON . stringify ( recentPadListData ) ) ;
54+
4055 // Remove duplicates based on pad name and sort by timestamp
4156 recentPadListData = recentPadListData . filter (
4257 ( pad , index , self ) => index === self . findIndex ( ( p ) => p . name === pad . name )
@@ -70,7 +85,7 @@ window.customStart = () => {
7085 li . style . cursor = 'pointer' ;
7186
7287 li . className = 'recent-pad' ;
73- const padPath = `${ window . location . href } p/${ pad . name } ` ;
88+ const padPath = `${ window . location . href } p/${ encodeURIComponent ( pad . name ) } ` ;
7489 const link = document . createElement ( 'a' ) ;
7590 link . style . textDecoration = 'none' ;
7691
Original file line number Diff line number Diff line change 11'use strict' ;
22
33const MAX_PADS_IN_HISTORY = 3 ;
4+ const decodePadSegment = ( segment ) => {
5+ try {
6+ return decodeURIComponent ( segment ) ;
7+ } catch {
8+ return segment ;
9+ }
10+ } ;
411
512window . customStart = ( ) => {
613 $ ( '#pad_title' ) . show ( ) ;
714 $ ( '.buttonicon' ) . on ( 'mousedown' , function ( ) { $ ( this ) . parent ( ) . addClass ( 'pressed' ) ; } ) ;
815 $ ( '.buttonicon' ) . on ( 'mouseup' , function ( ) { $ ( this ) . parent ( ) . removeClass ( 'pressed' ) ; } ) ;
916
1017 const pathSegments = window . location . pathname . split ( '/' ) ;
11- const padName = pathSegments [ pathSegments . length - 1 ] ;
18+ const padName = decodePadSegment ( pathSegments [ pathSegments . length - 1 ] ) ;
1219 const recentPads = localStorage . getItem ( 'recentPads' ) ;
1320 if ( recentPads == null ) {
1421 localStorage . setItem ( 'recentPads' , JSON . stringify ( [ ] ) ) ;
You can’t perform that action at this time.
0 commit comments