Jelajahi Sumber

Lua: fix line 1 syntax error that broke all of 5.1 compatibility

The very first line of client2server-unified.lua was:

  print("START
  ")--[[

with a LITERAL newline character between START and ", not the
two-character escape sequence \\n. Lua 5.1's lexer reads the
opening " then sees a raw LF inside the string, then ", then ),
which makes it an 'unfinished string near "START"' error.

This was introduced in commit 466fddc ('Print at start', 5 Jun 2026).
The script was never actually runnable on the router since that
commit. The Lua agent has presumably been dead for ~5 days.

Fix: replace the literal LF with \\n escape, so the string contains
the two characters S T A R T \ n (which Lua then expands to a
newline at print time).

Verified:
  - luac5.1 -p client2server-unified.lua   -> clean (2570 opcodes)
  - loadfile + coroutine resume            -> prints 'START', runs
  - all 50+ Lua 5.2+/5.3+/5.4 feature checks -> none used
  - no module()/setfenv/unpack/global goto -> all 5.1-safe
  - io.popen, string.char(0x81), string.char(0x88,0x00), math.floor
    division, % modulo on floats -> all 5.1-compatible

Audit checklist (all clean):
  - no goto / ::label::  (5.2+)
  - no integer type, no 0xNNp floats, no \\xNN escapes (5.3+)
  - no // floor div, no & | << >> bitwise ops (5.3+)
  - no utf8.* library (5.3+)
  - no table.move/pack/unpack (5.2+/5.3)
  - no string.pack/unpack/dump (5.3+)
  - no <close> attribute (5.4)
  - no 'continue' statement (5.2+)
  - no setfenv/getfenv (5.1 only, removed in 5.2)
  - no global 'unpack' (5.1 only; uses no unpack at all)
  - all io.popen results guarded with 'if f then'
  - all #table refs are on tables guaranteed non-nil
  - all function defs use standard 5.1 syntax
  - pcall used with single-arg form (5.1-safe)
  - coroutine.yield/resume/create only (5.1+)
  - no debug library usage
Luis Rosales 2 bulan lalu
induk
melakukan
ff7bf22d7a
1 mengubah file dengan 1 tambahan dan 2 penghapusan
  1. 1 2
      package/src/client2server-unified.lua

+ 1 - 2
package/src/client2server-unified.lua

@@ -1,5 +1,4 @@
-print("START
-")--[[
+print("START\n")--[[
     client2server-unified.lua - Bidirectional event forwarder for OpenWrt
     Copyright (c) 2026 Luis Rosales - MIT License