Skip to content

[Bug]:MediaUtils.getExtension() 的实现 bug #977

@xixincan

Description

@xixincan

它直接从 URL 字符串的最后一个 . 截取到末尾,没有处理 ? 之后的 query 参数:
// 框架内部逻辑(有 bug)
public static String getExtension(String path) {
int dotIndex = path.lastIndexOf('.');
int slashIndex = Math.max(path.lastIndexOf('/'), path.lastIndexOf('\'));
if (dotIndex <= slashIndex) return "";
return path.substring(dotIndex + 1);
}

Image

https://xxxx/image.png?Expires=xxx&Signature=xxx 提取出的"后缀"是 Expires=xxx&Signature=xxx,校验会失败。

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions