shosetsuorg / shosetsu

An android application for reading light novels. Moved to https://gitlab.com/shosetsuorg/shosetsu
https://shosetsu.app
GNU General Public License v3.0
584 stars 34 forks source link

[Bug] [2.0.0-1656] Malformed extension stops all extension updates/installs #161

Closed khonkhortisan closed 2 years ago

khonkhortisan commented 3 years ago

DANGEROUS TO TEST Describe the bug A malformed extension, for example one missing a comma… https://github.com/khonkhortisan/extensions/tree/stopupdates https://github.com/khonkhortisan/extensions/commit/ccb653bc7f6cb1254ac4802cdfd883a544655a3c

local crashattempt = {
    [0] = "A",
    [1] = "B",
    [2] = "C"
    [3] = "D",
    [4] = "E",
}

…will throw an error imagen and then also corrupt whatever manages updates/installs.

To Reproduce Steps to reproduce the behavior:

  1. DO NOT TRY THIS ON THE COPY OF SHOSETSU YOU READ NOVELS WITH, YOU WILL LOSE YOUR DATA you can install a second copy of shosetsu in a. android studio b. bluestacks l. lucky patcher
  2. optional: have RoyalRoad installed already
  3. add this repository url: https://raw.githubusercontent.com/khonkhortisan/extensions/stopupdates
  4. attempt to update RoyalRoad from 1.0.1 to 1.999.1 imagen
  5. it throws an error [string "ext(RoyalRoad)"]:7: '}' expected (to close '{' a..
    ========== (src/en/RoyalRoad.lua, LuaScript) ==========
    org.luaj.vm2.LuaError: [string "ext(RoyalRoad.lua)"]:7: '}' expected (to close '{' at line 3)
        at org.luaj.vm2.compiler.LexState.lexerror(Unknown Source)
        at org.luaj.vm2.compiler.LexState.syntaxerror(Unknown Source)
        at org.luaj.vm2.compiler.LexState.check_match(Unknown Source)
        at org.luaj.vm2.compiler.LexState.constructor(Unknown Source)
        at org.luaj.vm2.compiler.LexState.simpleexp(Unknown Source)
        at org.luaj.vm2.compiler.LexState.subexpr(Unknown Source)
        at org.luaj.vm2.compiler.LexState.expr(Unknown Source)
        at org.luaj.vm2.compiler.LexState.explist(Unknown Source)
        at org.luaj.vm2.compiler.LexState.localstat(Unknown Source)
        at org.luaj.vm2.compiler.LexState.statement(Unknown Source)
        at org.luaj.vm2.compiler.LexState.statlist(Unknown Source)
        at org.luaj.vm2.compiler.LexState.mainfunc(Unknown Source)
        at org.luaj.vm2.compiler.LuaC$CompileState.luaY_parser(Unknown Source)
        at org.luaj.vm2.compiler.LuaC$CompileState.access$000(Unknown Source)
        at org.luaj.vm2.compiler.LuaC.compile(Unknown Source)
        at org.luaj.vm2.Globals.compilePrototype(Unknown Source)
        at org.luaj.vm2.Globals.loadPrototype(Unknown Source)
        at org.luaj.vm2.Globals.load(Unknown Source)
        at org.luaj.vm2.Globals.load(Unknown Source)
        at org.luaj.vm2.Globals.load(Unknown Source)
        at app.shosetsu.lib.lua.LuaExtension.<init>(LuaExtension.kt:108)
        at app.shosetsu.lib.lua.LuaExtension.<init>(LuaExtension.kt:93)
        at TestKt.main(Test.kt:256)
    ' expected (to close '{' at line 3)
  6. it also crashes imagen
  7. extensions can be uninstalled, cannot be updated, cannot be installed a. Attempting to install an extension by clicking the imagen download icon or clicking the extension then clicking install will have no visible effect at first (the download icon will still be there) b. after going to another screen and back, the icon will change to a permanent spinning loading icon, with the version number gone imagen c. The version number can also be replaced with 'TODO', when ¿a previous version of the malformed extension was already installed? ¿after scrolling the Browse page? imagen d. disabling all repositories and refreshing shows the message "Obsolete extension! Please uninstall." under all installed extensions OR it could skip the malformed one based on [idk]
  8. What doesn't work to fix it:
    • clearing cache
    • stopping/restarting cycle workers
    • restarting the app
    • restarting the phone
    • disabling all repositories
    • force stop
  9. What does work to fix it:
    • clearing data WHICH DELETES ALL THE NOVELS IN THE LIBRARY
    • ¿waiting like a day?

Expected behavior If the extension is malformed, an error is thrown, with no permanent consequences

Screenshots If applicable, add screenshots to help explain your problem.

Device information:

AND

Additional context I accidentally did this to myself more than once because I was just using notepad++/git-bash/github/a phone/shosetsu without putting the extension through testing before installing it. If you program in the standard way where there are commas BETWEEN items {a,b,c} instead of AFTER items {a,b,c,} in a list, and you decide to reorder searchFilters or what's inside SOME_FILTER_INT by cut-pasting a line to a different place, this will happen {a,c b,}.

Doomsdayrs commented 3 years ago

I'll research this as soon as I finish repair of extension settings