Skip to content

Commit 1d487ab

Browse files
cs50victorCodex Agent
andauthored
fix: preserve language query when opening docs
* fix: forward editor lang through open redirect * docs: add NOTE on expected ISO 639-1 lang codes in open endpoint * test: add spawn timeout and simplify non-ASCII test paths --------- Co-authored-by: Codex Agent <codex@openinterpreter.com>
1 parent 8e131ee commit 1d487ab

2 files changed

Lines changed: 17 additions & 3 deletions

File tree

__tests__/generate-office-fonts-path.test.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ function runGenerator({ fontDataDir, writeOutputs }) {
7272
return spawnSync('node', [SCRIPT_PATH], {
7373
env,
7474
encoding: 'utf8',
75+
timeout: 10000,
7576
});
7677
}
7778

@@ -89,7 +90,7 @@ afterEach(() => {
8990
describe('generate_office_fonts path handling', () => {
9091
test('should succeed when FONT_DATA_DIR contains non-ASCII characters', () => {
9192
const root = makeTempDir('oo-editors-fontdata-');
92-
const fontDataDir = path.join(root, 'C', 'Users', 'دانيال', 'AppData', 'Roaming', 'interpreter', 'office-extension-fontdata');
93+
const fontDataDir = path.join(root, 'دانيال', 'fontdata');
9394

9495
const result = runGenerator({ fontDataDir, writeOutputs: true });
9596

@@ -100,7 +101,7 @@ describe('generate_office_fonts path handling', () => {
100101

101102
test('should fail when generator exits 0 but does not write metadata files', () => {
102103
const root = makeTempDir('oo-editors-fontdata-');
103-
const fontDataDir = path.join(root, 'C', 'Users', 'دانيال', 'AppData', 'Roaming', 'interpreter', 'office-extension-fontdata');
104+
const fontDataDir = path.join(root, 'دانيال', 'fontdata');
104105

105106
const result = runGenerator({ fontDataDir, writeOutputs: false });
106107

server.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -862,6 +862,8 @@ app.get('/load/:filename', (req, res) => {
862862
// ONLY supports absolute paths via query parameter
863863
app.get('/open', (req, res) => {
864864
const filepath = req.query.filepath;
865+
// NOTE(victor): OnlyOffice expects ISO 639-1 codes (e.g. "es", "fr"), not full names like "spanish"
866+
const lang = typeof req.query.lang === 'string' ? req.query.lang : '';
865867

866868
if (!filepath) {
867869
return res.status(400).json({ error: 'filepath query parameter is required' });
@@ -884,7 +886,18 @@ app.get('/open', (req, res) => {
884886
console.log(`[OPEN] Document URL: ${documentUrl}`);
885887

886888
// Redirect to offline loader with parameters
887-
res.redirect(`/offline-loader-proper.html?url=${encodeURIComponent(documentUrl)}&title=${encodeURIComponent(filename)}&filepath=${encodeURIComponent(filepath)}&filetype=${ext}&doctype=${docType}`);
889+
const redirectParams = new URLSearchParams({
890+
url: documentUrl,
891+
title: filename,
892+
filepath: String(filepath),
893+
filetype: ext,
894+
doctype: docType,
895+
});
896+
if (lang) {
897+
redirectParams.set('lang', lang);
898+
}
899+
900+
res.redirect(`/offline-loader-proper.html?${redirectParams.toString()}`);
888901
});
889902

890903
// API Endpoint: Serve raw/original file (not converted)

0 commit comments

Comments
 (0)