(<Unknown source>#5) in <Unknown source> at line number 5 at com.script.rhino.Rh...

2025年10月02日 11:21 响应: 1.86秒 状态: success

🚨 错误信息

com.script.ScriptException: org.mozilla.javascript.EvaluatorException: syntax error (<Unknown source>#5) in <Unknown source> at line number 5 at com.script.rhino.RhinoScriptEngine.eval(SourceFile:36) at com.script.AbstractScriptEngine.eval(SourceFile:3) at io.legado.app.model.analyzeRule.AnalyzeRule.evalJS(SourceFile:123) at io.legado.app.model.analyzeRule.AnalyzeRule.getString(SourceFile:32) at io.legado.app.model.analyzeRule.AnalyzeRule.getString$default(SourceFile:2) at io.legado.app.model.analyzeRule.AnalyzeRule.getString(SourceFile:11) at io.legado.app.model.webBook.w.a(SourceFile:8) at io.legado.app.model.webBook.w.b(SourceFile:34) at io.legado.app.model.webBook.x0.k(SourceFile:244) at io.legado.app.model.webBook.r0.invokeSuspend(SourceFile:41) at io.legado.app.model.webBook.r0.invoke(SourceFile:2) at io.legado.app.model.webBook.r0.invoke(SourceFile:1) at io.legado.app.help.coroutine.i.invokeSuspend(SourceFile:61) at l8.a.resumeWith(SourceFile:9) at kotlinx.coroutines.j0.run(SourceFile:127) at com.google.common.util.concurrent.u.h(SourceFile:6) at com.google.common.util.concurrent.u.run(SourceFile:9) at ka.k.run(SourceFile:3) at ka.b.run(SourceFile:96) Caused by: org.mozilla.javascript.EvaluatorException: syntax error (<Unknown source>#5) at org.mozilla.javascript.DefaultErrorReporter.runtimeError(SourceFile:23) at org.mozilla.javascript.DefaultErrorReporter.error(SourceFile:49) at org.mozilla.javascript.Parser.addError(SourceFile:19) at org.mozilla.javascript.Parser.reportError(SourceFile:6) at org.mozilla.javascript.Parser.reportError(SourceFile:4) at org.mozilla.javascript.Parser.reportError(SourceFile:1) at org.mozilla.javascript.Parser.primaryExpr(SourceFile:26) at org.mozilla.javascript.Parser.memberExpr(SourceFile:13) at org.mozilla.javascript.Parser.unaryExpr(SourceFile:193) at org.mozilla.javascript.Parser.expExpr(SourceFile:1) at org.mozilla.javascript.Parser.mulExpr(SourceFile:1) at org.mozilla.javascript.Parser.addExpr(SourceFile:1) at org.mozilla.javascript.Parser.shiftExpr(SourceFile:1) at org.mozilla.javascript.Parser.relExpr(SourceFile:1) at org.mozilla.javascript.Parser.eqExpr(SourceFile:1) at org.mozilla.javascript.Parser.bitAndExpr(SourceFile:1) at org.mozilla.javascript.Parser.bitXorExpr(SourceFile:1) at org.mozilla.javascript.Parser.bitOrExpr(SourceFile:1) at org.mozilla.javascript.Parser.andExpr(SourceFile:1) at org.mozilla.javascript.Parser.orExpr(SourceFile:1) at org.mozilla.javascript.Parser.condExpr(SourceFile:1) at org.mozilla.javascript.Parser.assignExpr(SourceFile:15) at org.mozilla.javascript.Parser.condExpr(SourceFile:25) at org.mozilla.javascript.Parser.assignExpr(SourceFile:15) at org.mozilla.javascript.Parser.assignExpr(SourceFile:64) at org.mozilla.javascript.Parser.expr(SourceFile:1) at org.mozilla.javascript.Parser.nameOrLabel(SourceFile:19) at org.mozilla.javascript.Parser.statementHelper(SourceFile:280) at org.mozilla.javascript.Parser.statement(SourceFile:6) at org.mozilla.javascript.Parser.statements(SourceFile:7) at org.mozilla.javascript.Parser.block(SourceFile:32) at org.mozilla.javascript.Parser.statementHelper(SourceFile:270) at org.mozilla.javascript.Parser.statement(SourceFile:6) at org.mozilla.javascript.Parser.getNextStatementAfterInlineComments(SourceFile:1) at org.mozilla.javascript.Parser.ifStatement(SourceFile:28) at org.mozilla.javascript.Parser.statementHelper(SourceFile:256) at org.mozilla.javascript.Parser.statement(SourceFile:6) at org.mozilla.javascript.Parser.parse(SourceFile:34) at org.mozilla.javascript.Parser.parse(SourceFile:6) at org.mozilla.javascript.Context.parse(SourceFile:20) at org.mozilla.javascript.Context.compileImpl(SourceFile:74) at org.mozilla.javascript.Context.compileReader(SourceFile:3) at org.mozilla.javascript.Context.evaluateReader(SourceFile:1) at com.script.rhino.RhinoScriptEngine.eval(SourceFile:27)<js> let pans=type(); if (pans=='漫画') { let burl=baseUrl; result=java.ajax(burl); page=String(java.getString('.pagination@a.-2@html',result)).match(/\>(\d+)\</)?.[1]||java.toast('不存在'); pageSum=parseInt(page);

🤖 AI解决方案

  • 错误翻译
  •     com.script.ScriptException: org.mozilla.javascript.EvaluatorException: syntax error (<Unknown source>#5)
        # 核心关键句:javascript 语法错误,在未知源的第 5 行。
        

  • 原因分析

  • JavaScript 代码在第 5 行存在语法错误。具体来说,page=String(java.getString('.pagination@a.-2@html',result)).match(/\>(\d+)\ 这一行使用了可选链操作符 ?.,但执行环境(Rhino JavaScript 引擎)可能不支持此 ES11 特性。

  • 解决方案

  • 移除可选链操作符 ?.,并进行空值检查。

        let pans = type();
        if (pans == '漫画') {
            let burl = baseUrl;
            result = java.ajax(burl);
            // 移除 ?. 并进行空值检查
            let matchResult = String(java.getString('.pagination@a.-2@html', result)).match(/\>(\d+)\</);
            page = matchResult ? matchResult[1] : java.toast('不存在');
            pageSum = parseInt(page);
        }
        

  • 预防措施

* 在使用较新的 JavaScript 语法特性前,确认代码的运行环境是否支持。
* 对可能为 null 或 undefined 的值进行显式检查,避免因依赖链式调用而引发错误。