Python url 查询中的字符 %7D 是什么意思?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/22510329/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 01:04:53  来源:igfitidea点击:

What do the chars %7D mean in an url query?

pythongoogle-app-engineurljinja2webapp2

提问by Niklas

If I access my webapp with the url

如果我使用 url 访问我的 webapp

/vi/5907399890173952.html

/vi/5907399890173952.html

then it works but when I look in the log files then googlebot is trying to access a similar url which generates an exception:

然后它可以工作,但是当我查看日志文件时,googlebot 正在尝试访问一个类似的 url,它会生成一个异常:

/vi/5907399890173952.html%7D%7D

/vi/5907399890173952.html%7D%7D

what does it mean and how can it be handled as an exception? The message from python is:

这是什么意思,如何作为异常处理?来自python的消息是:

 /vi/5251302833520640.html%7D%7D 404 20ms 0kb Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html) module=default version=release140319
66.249.67.109 - - [19/Mar/2014:07:53:32 -0700] "GET /vi/5251302833520640.html%7D%7D HTTP/1.1" 404 84 - "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)" ms=21 cpu_ms=0 cpm_usd=0.000009 app_engine_release=1.9.1 instance=00c61b117c0bc0f980f2a37a6ac534786055d3ab
E 2014-03-19 15:53:32.678
get() takes exactly 3 arguments (2 given)

The regex that I use for the url is

我用于网址的正则表达式是

('/vi/(\d+)(\.html?)?', NewHandler)

('/vi/(\d+)(\.html?)?', NewHandler)

Update 140319 21:54 CET

更新 140319 21:54 CET

I think I've found the leakage from a jinja2 template:

我想我发现了 jinja2 模板的泄漏:

{{scored_document.fields.0.value|safe}

{{scored_document.fields.0.value|safe}

I patched it with another }now.

我现在用另一个修补它}

采纳答案by Martin Berends

%7Dis the ASCII code for the } character, which is probably leaking through from a template...

%7D是 } 字符的 ASCII 代码,它可能是从模板中泄漏出来的......