Url 如何对URI进行编码以安全地存储在TableServiceEntity的RowKey中?
我非常非常希望在Azure表存储中存储URI作为行键值。根据,行键不能包含URI中常见的字符(/,\,#,?) 解决方案似乎很简单:只需对URI进行编码。但这不起作用。无论出于何种原因,都可以插入包含序列%2f(正斜杠的编码值)的任何值,但即使“%2f”不包含任何禁止的字符,也不能查询 好的,那么base64编码呢?不。它偶尔会产生正斜杠字符,这是不允许的 那么,有没有一种编码字符串(URI)的方法可以可靠地存储为Azure表中的RowKey呢?最好是,但不一定是人类可读的东西。一些可能性:Url 如何对URI进行编码以安全地存储在TableServiceEntity的RowKey中?,url,uri,azure-storage,azure-table-storage,Url,Uri,Azure Storage,Azure Table Storage,我非常非常希望在Azure表存储中存储URI作为行键值。根据,行键不能包含URI中常见的字符(/,\,#,?) 解决方案似乎很简单:只需对URI进行编码。但这不起作用。无论出于何种原因,都可以插入包含序列%2f(正斜杠的编码值)的任何值,但即使“%2f”不包含任何禁止的字符,也不能查询 好的,那么base64编码呢?不。它偶尔会产生正斜杠字符,这是不允许的 那么,有没有一种编码字符串(URI)的方法可以可靠地存储为Azure表中的RowKey呢?最好是,但不一定是人类可读的东西。一些可能性: 使
我肯定还有其他想法,我很想听听 离题但相关:我正在动态创建表,如果您需要,我的代码可能会对您有所帮助,尽管表和PK/RK的规则非常不同。“^[A-Za-z][A-Za-z0-9]{2,62}$” 也许你可以用它来启发你自己的解决方案 解码字符串
string edit1 = host
.Replace("qqu", "_")
.Replace("qqh", "-")
.Replace("qqp", ".")
// NOTE: qqn is reserved leading sequence
.Replace("qqt", "qqu")
.Replace("qqo", "qqp")
.Replace("qqg", "qqh")
;
if (edit1.StartsWith("qqn"))
{
edit1 = edit1.Substring(3, edit1.Length);
}
if (edit1.StartsWith("qq"))
{
edit1 = edit1.Substring(2, edit1.Length);
}
string edit1 = this.originalName.ToLower().Trim()
.Replace("qqu", "qqt")
.Replace("qqp", "qqo")
.Replace("qqh", "qqg")
// NOTE: qqn is reserved leading sequence
.Replace("_", "qqu")
.Replace("-", "qqh")
.Replace(".", "qqp");
string test = "qq";
if (edit1.StartsWith(test))
return test + "n" + edit1;
test = "0";
if (edit1.StartsWith(test))
return "qq" + edit1;
test = "1";
if (edit1.StartsWith(test))
return "qq" + edit1;
test = "2";
if (edit1.StartsWith(test))
return "qq" + edit1;
test = "3";
if (edit1.StartsWith(test))
return "qq" + edit1;
test = "4";
if (edit1.StartsWith(test))
return "qq" + edit1;
test = "5";
if (edit1.StartsWith(test))
return "qq" + edit1;
test = "6";
if (edit1.StartsWith(test))
return "qq" + edit1;
test = "7";
if (edit1.StartsWith(test))
return "qq" + edit1;
test = "8";
if (edit1.StartsWith(test))
return "qq" + edit1;
test = "9";
if (edit1.StartsWith(test))
return "qq" + edit1;
test = "0";
if (edit1.StartsWith(test))
return "qq" + edit1;
方法对字符串进行编码
string edit1 = host
.Replace("qqu", "_")
.Replace("qqh", "-")
.Replace("qqp", ".")
// NOTE: qqn is reserved leading sequence
.Replace("qqt", "qqu")
.Replace("qqo", "qqp")
.Replace("qqg", "qqh")
;
if (edit1.StartsWith("qqn"))
{
edit1 = edit1.Substring(3, edit1.Length);
}
if (edit1.StartsWith("qq"))
{
edit1 = edit1.Substring(2, edit1.Length);
}
string edit1 = this.originalName.ToLower().Trim()
.Replace("qqu", "qqt")
.Replace("qqp", "qqo")
.Replace("qqh", "qqg")
// NOTE: qqn is reserved leading sequence
.Replace("_", "qqu")
.Replace("-", "qqh")
.Replace(".", "qqp");
string test = "qq";
if (edit1.StartsWith(test))
return test + "n" + edit1;
test = "0";
if (edit1.StartsWith(test))
return "qq" + edit1;
test = "1";
if (edit1.StartsWith(test))
return "qq" + edit1;
test = "2";
if (edit1.StartsWith(test))
return "qq" + edit1;
test = "3";
if (edit1.StartsWith(test))
return "qq" + edit1;
test = "4";
if (edit1.StartsWith(test))
return "qq" + edit1;
test = "5";
if (edit1.StartsWith(test))
return "qq" + edit1;
test = "6";
if (edit1.StartsWith(test))
return "qq" + edit1;
test = "7";
if (edit1.StartsWith(test))
return "qq" + edit1;
test = "8";
if (edit1.StartsWith(test))
return "qq" + edit1;
test = "9";
if (edit1.StartsWith(test))
return "qq" + edit1;
test = "0";
if (edit1.StartsWith(test))
return "qq" + edit1;
将URL中所有非法的行键字符(\,/,?)替换为URL中非法的字符(例如,%)在使用base64编码后将/替换为uu应该可以工作。
从获得此建议。此建议无效,因为不允许使用某些(未记录的)字符序列。一个已知序列是%2f。这允许使用查询启动