Sync snapshot (2026-08-02)
This commit is contained in:
@@ -110,6 +110,11 @@ export async function buildDocx(options: BuildDocxOptions): Promise<Uint8Array>
|
||||
`${XML_DECL}<w:document ${DOC_NS}><w:body>${options.bodyXml}${sectPr}</w:body></w:document>`,
|
||||
)
|
||||
|
||||
// Pin zip entry mtimes (JSZip defaults them to "now") so regenerating the
|
||||
// committed fixtures is byte-deterministic and CI can diff for drift.
|
||||
zip.forEach((_path, entry) => {
|
||||
entry.date = new Date(Date.UTC(2026, 0, 1))
|
||||
})
|
||||
return zip.generateAsync({ type: 'uint8array', compression: 'DEFLATE' })
|
||||
}
|
||||
|
||||
@@ -119,8 +124,7 @@ export const IMAGE_PARAGRAPH_XML =
|
||||
'<pic:pic><pic:blipFill><a:blip r:embed="rId10"/></pic:blipFill></pic:pic>' +
|
||||
'</a:graphicData></a:graphic></wp:inline></w:drawing></w:r></w:p>'
|
||||
|
||||
export const MATH_PARAGRAPH_XML =
|
||||
'<w:p><m:oMath><m:r><m:t>E=mc^2</m:t></m:r></m:oMath></w:p>'
|
||||
export const MATH_PARAGRAPH_XML = '<w:p><m:oMath><m:r><m:t>E=mc^2</m:t></m:r></m:oMath></w:p>'
|
||||
|
||||
export const CHART_PARAGRAPH_XML =
|
||||
'<w:p><w:r><w:drawing><wp:inline><wp:extent cx="5486400" cy="3200400"/>' +
|
||||
@@ -137,9 +141,7 @@ const chartStrCache = (values: string[], f: string) =>
|
||||
const chartNumCache = (values: (number | null)[], f: string) =>
|
||||
`<c:numRef><c:f>${f}</c:f><c:numCache><c:formatCode>General</c:formatCode>` +
|
||||
`<c:ptCount val="${values.length}"/>` +
|
||||
values
|
||||
.map((v, i) => (v === null ? '' : `<c:pt idx="${i}"><c:v>${v}</c:v></c:pt>`))
|
||||
.join('') +
|
||||
values.map((v, i) => (v === null ? '' : `<c:pt idx="${i}"><c:v>${v}</c:v></c:pt>`)).join('') +
|
||||
'</c:numCache></c:numRef>'
|
||||
|
||||
/** bar chart part: title, 2 series over 3 categories, with a gap in series 2 */
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
export { installNavigationGuard } from './navigation-guard'
|
||||
export { safeExternalUrl, type SafeExternalUrlOptions } from './safe-external-url'
|
||||
export {
|
||||
fetchWithSsrfGuard,
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
/// App-wide navigation lockdown for every webContents in the suite.
|
||||
///
|
||||
/// Every renderer is a local single-page app loaded exactly once via
|
||||
/// loadFile/loadURL (which do not emit will-navigate), so a full-page
|
||||
/// navigation is never part of normal operation — it can only come from
|
||||
/// hostile document content or AI-generated markup. The guard blocks all of
|
||||
/// them except same-URL reloads (used by dev tooling), and installs a
|
||||
/// default-deny window.open handler.
|
||||
///
|
||||
/// Apps that intentionally route window.open links to the system browser
|
||||
/// (docs/slides/pdf via safeExternalUrl) install their own handler on
|
||||
/// specific webContents after creation; that replaces the default-deny
|
||||
/// handler for those contents only.
|
||||
import type { App } from 'electron'
|
||||
|
||||
// Symbol.for: the flag survives multiple bundled copies of this module
|
||||
// (each app bundle ships its own electron-utils, and the shell hosts all of
|
||||
// them in one process).
|
||||
const INSTALLED = Symbol.for('genoffice.navigation-guard-installed')
|
||||
|
||||
export function installNavigationGuard(app: App): void {
|
||||
const holder = app as unknown as Record<symbol, boolean | undefined>
|
||||
if (holder[INSTALLED]) return
|
||||
holder[INSTALLED] = true
|
||||
app.on('web-contents-created', (_event, contents) => {
|
||||
contents.on('will-navigate', (event) => {
|
||||
if (event.url !== contents.getURL()) event.preventDefault()
|
||||
})
|
||||
contents.setWindowOpenHandler(() => ({ action: 'deny' }))
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user