Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Pack 005c: System Evaporation #64

Merged
merged 34 commits into from
Oct 6, 2020

Conversation

IepIweidieng
Copy link
Member

@IepIweidieng IepIweidieng commented Oct 6, 2020

Relevant issues: #45

Fix Pack 005c Change Log (en-US)

Fixes relevant to user experience

  • Now a warning prompt displays when users try to lock their post but do not have the moderator permission to unlock the post.
  • Fix exiting from the Ctrl-Z menu triggers the welcome screen of the current board.
  • Fix idling guests get disconnected abnormally
  • Fix the kicker session's pid wrongly logged as the kicked session's pid when the previous session is kicked due to multi-session
  • Now a lot of screens automatically redraw when the screen resizes, e.g., xover(), popupmenu(), vget().
  • Add xover command XO_CUR + pos. This command redraws the item under the cursor and then relatively moves the cursor, so that the relevant function is simplified and improved

Fixes relevant to BBS architecture

  • Rewrite the main menu to be compatible with xover architecture.
    Some commands for main menu were changed to be consistent with xover list.
    Please re-compile the programs, since the macro values have been changes.
  • Unify the special values used by the data structure for the main menu and for the popupmenu to improve the ease of maintenance.
    Now the POPUP_* macros for popupmenu are not used in the internal code.
    Please re-compile the programs, since the macro values have been changed.
  • Deprecate iac_count() in favor of the new bound-checking iac_process()
  • Add new system program–calling functions which do not depend on the shell to replace system() function calls to improve security

Other fixes

  • Fix mailpost ignores bottomed posts
  • Fix pmore not correctly handling key \0 (fixed in PttBBS beforehand)
  • Replace some hardcoded paths.
  • Other minor fixes. For details, please see the commit log

Fix Pack 005c Change Log (zh-TW)

與使用者體驗有關的修正

  • 現在鎖文時,如果沒有板主權限而不能自行解鎖,會先顯示警告訊息要使用者確認
  • 修正從 Ctrl-Z 選單離開會跳出進板畫面的問題
  • 修正訪客閒置時異常斷線
  • 修正踢除重複連線時,踢人的 pid 被誤當成被踢的 pid 記錄
  • 現在許多畫面在螢幕大小變更時會自動重繪,如 xover() 列表、popupmenu() 選單、vget() 訊息
  • 新增 xover 指令 XO_CUR + pos,此指令可重繪游標所在的項目再相對移動游標,簡化並改善了相關功能的處理

與 BBS 架構有關的修正

  • 改寫主選單以符合 xover 架構,並將一部分指令改成與 xover 指令相同。
    Macro 值改了,請重新編譯。
  • 統一主選單與彈出式選單的資料結構所用的特殊值,以方便維護。
    內部處理程式不再使用彈出式選單的 POPUP_* macros。
    Macro 值改了,請重新編譯。
  • 棄用 iac_count(),改用新的有邊界檢查的 iac_process()
  • 新增不須使用 shell 的系統程式呼叫函式取代部分 system() 函式呼叫,改善安全性

其它修正

  • 修正 mailpost 忽略置底文章的問題
  • 修正 pmore 不正確處理 \0 按鍵的問題(已先在 PttBBS 修正)
  • 取代一些寫死的路徑
  • 其它小修正,請見 commit 紀錄

- maple/acct.c: `m_register()`
- maple/mail.c: `m_setmboxdir()`
…iac_count()`

- Rewrite `iac_count()` into `iac_process()`
- Add another `iac_count()` function implemented with `iac_process()`
   for backward compatibility.
- `igetch()`: Replace the use of `iac_count()` with `iac_process()`.
- maple/visio.c:
   - `iac_process()`: Return `I_RESIZETERM` for term size changes.
   - `char_opt()`: Forward the special key value `I_RESIZETERM`.
- maple/menu.c: `domenu()`
- maple/popupmenu.c: `do_menu()` & `popupmenu_ans()`
- maple/window.c: `popupmenu_ans2()`
- maple/visio.c: `vget()`
…orming relative move

- Replace codes like:
```cpp
move(3 + cur, 0);
sth_item(pos + 1, sth);
cursor_show(3 + cur, 0);
return XR_FOOT + XO_MOVE + XO_REL + 1;
```
with:
```cpp
move(3 + cur, 0);
sth_item(pos + 1, sth);
return XR_FOOT + XO_CUR + 1;
```
…r()`

- `int xover_exec_cb(XO *xo, int cmd)`
- `int xover_key(XO *xo, int zone, int cmd)`

- Reduce variable scope and eliminate reused variables
- Rewrite unnecessary assignments into `return` statements
- Fix the stack level counter not decreasing
   when the user exits from a full mailbox
- Implement `*_cur()` callback functions
   and add them to the callback tables
- Replace codes like:
```cpp
move(3 + cur, 0);
sth_item(pos + 1, sth);
return XR_FOOT + XO_CUR + 1;
```
with:
```cpp
return XR_FOOT + XO_CUR + 1;
```
- `every_Z()`: Pass parameter `xo` to `popupmenu()`
- Extract main menu redraw codes into xover callback functions.
- Add xover zone flag `XZ_SKIN` for changing skin;
   usage: `XO_SKIN + {XO_WRAP|XO_SCRL|XO_REL} + skin_index`.
   (`XO_SKIN` = `(XZ_ZONE | XZ_SKIN) + XO_MOVE`)
- Redefine menu commands `XEASY`, `QUIT`, & `SKIN` as xover commands.
- Extract function `domenu_exec()` from `domenu()`
   for executing a single command.
- `domenu_exec()`:
   Pass `XO` object to `every_Z()` for handling term resizing.
- Use `move_ansi()` to move for printing explanation.
- Add `DomenuXyz::explan_len_prev`
   to store the length of the last displayed explanation.
- Clean the last displayed explanation before printing the current one.
- Add lengthed length function `strip_ansi_n_len()`.
- Exclude the item explanation from `item_length` calculation.
…union type `DlMenuItem`

- maple/popupmenu.c: `do_cmd()`: Refine code for handling `M_DL(umode)`.
…enu system

- Add user mode alias macros: `M_MENU` & `M_FUN`.
- Add user mode flag macros:
   `M_QUIT`, `M_XO`, `M_DOINSTANT`, `M_MENUTITLE`, & `M_TAIL_MASK`.
- Reassign the value of macro `M_ARG`.
- Make macro `M_DL()` a flag to avoid negative numbers.
- Change the type of `MENU::umode` from `int` to `unsigned int`.

- Implement `M_XO`.
   - Add `FuncArg::xofunc` & `DlFuncArg::xofunc`.
- Add `DlMenuItem` members which correspond to the members of `MenuItem`.

- Move the definitions of macro `PERM_MENU` into `include/modes.h`.
- Unify the condition for determining the tail element of a menu list.

- Remove macros `POPUP_MASK` & `POPUP_DO_INSTANT`.
- Redefine remaining `POPUP_*` macros with the new `M_*` macros.
…welcome screen

This also fixes the issue that `BRD_V_BIT` is never set for boards without
the welcome screen.
- Add new functions `proc_runv()` and `proc_runl()`.
- Add new macro `PROC_CMD()`.
…C_CMD()`

- Use hardcoded path for system executables for security
- Use `/bin/sh` for executing shell scripts
   (use `#!/usr/bin/env bash` in scripts
      to make them executed by `bash` instead)
… xterm-style)

The macro `ANSI_IS_PARAM()` is changed to accept `':'`
   for parsing ECMA-48-style parameter elements of a parameter substring.
- maple/pmore.c:
    - Add macro `MOVIE_KEY_NONE`.
    - Make `mf_movieWaitKey()` return `MOVIE_KEY_NONE` on timeouts.
    - Make `mf_movieNamedKey()` return `MOVIE_KEY_NONE` for invalid
keys.
    - `mf_movieOptionHandler()`:
        - Initialize variable `c` to `MOVIE_KEY_NONE` rather than `0`.

This command makes pmore hang:
```
0c 23 00 2c 66 31 23 0a 30 ab ab ab ab ab ab
```

In plaintext with mix of caret notation and C escape sequences:
```
^L#\0,f1#
0\xab\xab\xab\xab\xab\xab
```

Where:
```
^L#\0,f1#
```
sets up a interactive choice with one option without the prompt.

It literally means to go to the 1st frame
   when the user send `'\0'` (`Ctrl-Shift-2` on PCMan),
   although `'\0'` is an invalid choice key.

But there is a logic error in `mf_movieOptionHandler()`:
```c
                // handle selection
                if (c == key ||
                        (key == MOVIE_KEY_ANY && c != 0))
                {
                    // hotkey pressed
                    selected = 1;
                    isel = maxsel;
                }
```
When `^L#\0,f1#` is processed,
   the variable `key` is `'\0'`,
   and the variable `c` is its initial value, which is also `0`.

This makes the program think that the hotkey `'\0'` is pressed
   even if the user presses nothing,
   and therefore no user inputs will be processed.

Then the command `f1` will be executed in `mf_movieExecuteOffsetCmd()`,
   making the pmore interpreter go to the 1st frame,
   where `^L#\0,f1#` resides.

The pmore interpreter will then enter a infinity loop
   which repeatly executes `^L#\0,f1#` and skips user inputs
      due to the logic error aforementioned,
   which makes the interpreter ignore user inputs and hang forever.

There are 2 ways to fix the issue:

1. Modify the condition to always check `c` against `0`.
   This is the simple way but is only a workaround.

2. Introduce another special `vget()` value which `vget()` never
returns,
      to distinguish _nothing_ from `'\0'`.
   This also makes pmore correctly handle `'\0'` as a normal key
      (but still an invalid choice key).

The 2nd way was chosen since it make the intention of the code clearer.
- Add function `blog_pid` for calling `blog` with `pid` specified
- `tn_login()`: Use `blog_pid()` to log the kick event
@holishing holishing merged commit ebc07f2 into ccns:master Oct 6, 2020
@github-pages github-pages bot temporarily deployed to github-pages October 6, 2020 19:41 Inactive
@IepIweidieng IepIweidieng deleted the fixpack005c-System-Evaporation branch October 6, 2020 20:03
IepIweidieng added a commit that referenced this pull request May 3, 2021
IepIweidieng added a commit that referenced this pull request May 3, 2021
IepIweidieng added a commit that referenced this pull request May 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants