Keep url encoded while using URI class

后端 未结 2 1160
野趣味
野趣味 2020-12-06 11:30

I\'m trying to get public profile information from LinkedIn. To achieve this I have to provide
http://api.linkedin.com/v1/people/url=public-profile-url, where public-pro

相关标签:
2条回答
  • 2020-12-06 11:34

    There is report about that on Microsoft connect. By default escaped slashes not allowed due to security reasons.

    http://connect.microsoft.com/VisualStudio/feedback/details/94109/

    Cites from there:

    I try to use the LinkedIn api, for which I need the following link: http://api.linkedin.com/v1/people/url=http%3A%2F%2Fwww.linkedin.com%2Fin%2Fyourlinkedinname:public

    As you can see the url field needs to be escaped. How to solve this?

    Answer:

    We currently don't allow escaped slashes and dots to appear in the path because this is a common way to attacker a server when the URI scheme supports path compression.

    But there is tab with workarounds. One of them for .NET 4 is to add app.config:

    For .NET 4.0, you can control this through the config file:

    http://msdn.microsoft.com/en-us/library/bb882619.aspx

    http://msdn.microsoft.com/en-us/library/ee656539.aspx

    <configuration>
    <uri>
        <schemeSettings>
         <clear/>
         <add name="http" genericUriParserOptions="DontUnescapePathDotsAndSlashes"/>
        </schemeSettings>
    </uri>
    </configuration>
    

    For .NETs before .NET was constructor for Uri class with parameter "dontEscape". For .NET 4 it's obsolete.

    0 讨论(0)
  • 2020-12-06 11:51

    What happens if you double escape it?

    http://api.linkedin.com/v1/people/url=http%253a%252f%252fwww.linkedin.com%252fin%252fiftachragoler
    
    0 讨论(0)
提交回复
热议问题