dsh-unlag 1.9.99 → 1.9.100

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.js +11 -2
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -830,12 +830,19 @@ function buttonAllowed(req) {
830
830
  return false
831
831
  }
832
832
  const origin = typeof req?.headers?.origin === 'string' ? req.headers.origin.trim().toLowerCase() : ''
833
- if (origin === 'null') return false
833
+ // An opaque origin belongs to a document this machine did not open, and an origin that cannot
834
+ // be read is one this check cannot judge. Both are refused, and both say so: a refusal nobody
835
+ // can find afterwards is the kind of silence that makes a wrong answer look like a right one.
836
+ if (origin === 'null') {
837
+ log('refused a press from an opaque origin')
838
+ return false
839
+ }
834
840
  if (origin !== '') {
835
841
  let originSite = ''
836
842
  try {
837
843
  originSite = new URL(origin).host.toLowerCase() // ui-copy-ignore
838
844
  } catch {
845
+ log(`refused a press from an origin that is not an address: ${oneLine(origin, 200)}`)
839
846
  return false
840
847
  }
841
848
  if (originSite !== site) {
@@ -1936,8 +1943,10 @@ function serveButton(ctx, controller, config) {
1936
1943
  * A page on any site can post to a local address without asking first, and a log is
1937
1944
  * evidence: a made-up outcome must not get in. The header the page's own script sends
1938
1945
  * makes the request one a browser has to ask about first, and this app never agrees.
1946
+ * The same address check the press uses applies here too: the log is the record a press
1947
+ * leaves behind, so a page that may not press may not write into it either.
1939
1948
  */
1940
- if (typeof req?.headers?.[BUTTON_HEADER] !== 'string') return sendJson(res, 403, { status: 'forbidden' })
1949
+ if (buttonAllowed(req) === false) return sendJson(res, 403, { status: 'forbidden' })
1941
1950
  let query = ''
1942
1951
  try {
1943
1952
  query = new URL(String(req?.url ?? ''), 'http://x').searchParams.toString()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-unlag",
3
- "version": "1.9.99",
3
+ "version": "1.9.100",
4
4
  "type": "module",
5
5
  "description": "A press applies plugin edits right away and brings a laggy interface back; automatic reloading stays off unless you turn it on, so the press is the only trigger, and nothing restarts.",
6
6
  "license": "MIT",