Double slashes in urls in Outlook

2019-04-09 09:00发布

The url of our search page is build like this:
http://www.example.com/results/name/John/city/Miami/gender/Male This would display every male named John in Miami.

When one of the filters is left empty, the url would be something like this:
http://www.example.com/results/name/John/city//gender/Male
So there are two slashes in the url.

Outlook doesn't seem to like this. When you click on the second url, it removes one of the two slashes. This leaves the url like this:
http://www.example.com/results/name/John/city/gender/Male
Persons names John in the city 'gender'..

What would be the best way to fix this problem?

标签: url outlook
7条回答
Summer. ? 凉城
2楼-- · 2019-04-09 09:43

"Regkey" should help: You need to implement this key

Path: "HKEY_CURRENT_USER\Software\Microsoft\Office\Common"
Name: "AllowConsecutiveSlashesInUrlPathComponent"
Type: "REG_DWORD"
Value: "1"

For implementation & more detail see here.

查看更多
等我变得足够好
3楼-- · 2019-04-09 09:47

I agree with Peter, just replace the second "/" with "%2F" or "%2f" is enough.

查看更多
Bombasti
4楼-- · 2019-04-09 09:49

This is a bug in Microsoft Office.

URLs with two consecutive slashes are allowed by RFC 2396, but they're not commonly used. As the RFC says (extract from Appendix A):

abs_path      = "/"  path_segments
path_segments = segment *( "/" segment )
segment       = *pchar *( ";" param )

Note that segment is defined as containing ZERO OR MORE characters. (You might argue that this is a spec bug, and it shouldn't be allowed... but it is)

As you've discovered, Microsoft Office will "fix" URLs containing double slashes. This is apparently a deliberate feature for "cleanliness and consistency". There is no way to override or disable it. Source.

So, as other people have suggested, you're probably going to have to change the way the server formats URLs.

查看更多
走好不送
5楼-- · 2019-04-09 09:50

You can use - instead of blank segment. For example:

http://www.example.com/results/name/John/city/-/gender/Male

查看更多
甜甜的少女心
6楼-- · 2019-04-09 09:52

Try to replace (one of) the slashes with ASCII code 2F (decimal 47).

查看更多
爷、活的狠高调
7楼-- · 2019-04-09 09:58

If you must use slashes, consider fixing this on the server side. Create a list of keywords (city|results|...) and, if a slash is followed by one of the keywords, treat it as an empty entry. (edited) Double slashes should not be treated as one, but as you found out, some applications "fix" this.

An alternative and standard way of fixing this is using a placeholder, normally a dot, because it has no special meaning:

http://example.com/results/name/./city/amsterdam

查看更多
登录 后发表回答