Skip to content

bug: 开启隐私/去广告插件时,UA 解析逻辑导致评论提交崩溃 #1116

@tjsky

Description

@tjsky

问题描述:在评论者使用了 AdGuard 或某些隐私增强扩展时,navigator.userAgentData.getHighEntropyValues 可能返回不完整的对象(缺少 platformVersion 字段),导致无法提交评论。

感觉应该是 bui/artalk/src/lib/ua.ts 的这部分函数

  const uaData = (navigator as any).userAgentData
  let uaGot: any = null
  try {
    uaGot = await uaData.getHighEntropyValues(['platformVersion'])
  } catch (err) {
    console.error(err)
    return uaRaw
  }
  const majorPlatformVersion = Number(uaGot.platformVersion.split('.')[0])

若隐私增强扩展抹除了信息,使得 n.platformVersionundefined 时就会引发崩溃,直接阻断 JS 的执行线程,导致无法提交评论,建议加个非空判断之类的东西。

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions