Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion admin/src/pages/PadPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ export const PadPage = () => {
</button>
<button
className="pm-btn pm-btn-primary pm-btn--sm"
onClick={() => window.open(`../../p/${pad.padName}`, '_blank')}
onClick={() => window.open(`../../p/${encodeURIComponent(pad.padName)}`, '_blank')}
>
<Eye size={13}/> <Trans i18nKey="admin_pads.open"/>
</button>
Expand Down
10 changes: 9 additions & 1 deletion src/static/js/pad_userlist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ const chat = require('./chat').chat;
import html10n from './vendors/html10n';
let myUserInfo = {};

const decodePadSegment = (segment: string): string => {
try {
return decodeURIComponent(segment);
} catch {
return segment;
}
};

let colorPickerOpen = false;
let colorPickerSetup = false;

Expand Down Expand Up @@ -557,7 +565,7 @@ const paduserlist = (() => {
if (localStorage.getItem('recentPads') != null) {
const recentPadsList = JSON.parse(localStorage.getItem('recentPads'));
const pathSegments = window.location.pathname.split('/');
const padName = pathSegments[pathSegments.length - 1];
const padName = decodePadSegment(pathSegments[pathSegments.length - 1]);
const existingPad = recentPadsList.find((pad) => pad.name === padName);
if (existingPad) {
existingPad.members = online;
Expand Down
17 changes: 16 additions & 1 deletion src/static/skins/colibris/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
'use strict';

const decodePadName = (name) => {
try {
return decodeURIComponent(name);
} catch {
return name;
}
};

window.addEventListener('pageshow', (event) => {
if (event.persisted) {
if (document.readyState === 'complete' || document.readyState === 'interactive') {
Expand Down Expand Up @@ -37,6 +45,13 @@ window.customStart = () => {
recentPadListData = JSON.parse(recentPadsFromLocalStorage);
}

// Normalize older entries that stored encoded names (e.g. Test%2F123).
recentPadListData = recentPadListData.map((pad) => ({
...pad,
name: decodePadName(String(pad.name ?? '')),
}));
localStorage.setItem('recentPads', JSON.stringify(recentPadListData));

// Remove duplicates based on pad name and sort by timestamp
recentPadListData = recentPadListData.filter(
(pad, index, self) => index === self.findIndex((p) => p.name === pad.name)
Expand Down Expand Up @@ -70,7 +85,7 @@ window.customStart = () => {
li.style.cursor = 'pointer';

li.className = 'recent-pad';
const padPath = `${window.location.href}p/${pad.name}`;
const padPath = `${window.location.href}p/${encodeURIComponent(pad.name)}`;
const link = document.createElement('a');
link.style.textDecoration = 'none';

Expand Down
9 changes: 8 additions & 1 deletion src/static/skins/colibris/pad.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
'use strict';

const MAX_PADS_IN_HISTORY = 3;
const decodePadSegment = (segment) => {
try {
return decodeURIComponent(segment);
} catch {
return segment;
}
};

window.customStart = () => {
$('#pad_title').show();
$('.buttonicon').on('mousedown', function () { $(this).parent().addClass('pressed'); });
$('.buttonicon').on('mouseup', function () { $(this).parent().removeClass('pressed'); });

const pathSegments = window.location.pathname.split('/');
const padName = pathSegments[pathSegments.length - 1];
const padName = decodePadSegment(pathSegments[pathSegments.length - 1]);
const recentPads = localStorage.getItem('recentPads');
if (recentPads == null) {
localStorage.setItem('recentPads', JSON.stringify([]));
Expand Down