Firestore 安全规则是否支持非ASCII集合名称的编写方式?

huangapple go评论60阅读模式
英文:

is there a way to write Firsestore security rules for non-ASCII collection names?

问题

Many of my Firestore documents and collections are named in Arabic, but when I want to write security rules I noticed Arabic text is not accepted?
I need help on how to fix that?

I tried many types to write the Arabic collection names in the Security rules, but not accepted by Firebase and I couldn't find any useful solution on the Internet for this case.

英文:

Many of my Firestore documents and collections are named in Arabic, but when I want to write security rules I noticed Arabic text is not accepted?
I need help on how to fix that?

I tried many types to write the Arabic collection names in the Security rules, but not accepted by Firebase and I couldn't any useful solution on the Internet for this case.

答案1

得分: 2

以下是要翻译的内容:

firebaser here: I thought we'd covered this before, but can't find it - so I checked with the engineering team.

在您的规则定义中,路径段只能包含[A-Za-z0-9]以及一些特殊字符,如*%。对于其他字符,您应该使用十六进制/URL转义(使用%)。

所以,如果我有一个名为één的集合,我会有一个匹配它的规则,如下所示:

match /%C3%A9%C3%A9n/{docid} {
  allow read;
}

其中的%C3%A9%C3%A9n是集合名称één的URL编码,在这种情况下,通过执行encodeURI('één')获取。

英文:

firebaser here: I thought we'd covered this before, but can't find it - so I checked with the engineering team.

The path segment in your rules definition may only contain [A-Za-z0-9] plus some special characters like * and %. For other characters, you can should use hex/URL escaping (using %).

So if I have a collection named één, I'd have a rule matching it as:

match /%C3%A9%C3%A9n/{docid} {
  allow read;
}

The %C3%A9%C3%A9n in there is the URL encoding of the collection name één, in this case gotten by doing encodeURI('één').

huangapple
  • 本文由 发表于 2023年1月9日 17:15:18
  • 转载请务必保留本文链接:https://go.coder-hub.com/75055146.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定