|
Rank: Newbie Groups: Member
Joined: 9/12/2012 Posts: 8
|
I downloaded the latest version yesterday and tried to use the Cookies option to handle a security issue I am having rendering a URL. Essentially I want to set the custom auth session key from the currently logged in user to the Options for rendering the URL. The set goes as follows:
System.Net.Cookie tmp = new System.Net.Cookie(); tmp .Name = Common.SessionManager.gsCookie; tmp .Path = "/"; tmp .Value = Request.Cookies[Common.SessionManager.gsCookie].Value; cookies.Add(tnp);
EO.Pdf.HtmlToPdf.Options.Cookies.Add(cookies);
When I make the call to do the convert and check the value of the sessionkey, it appears as it if was encoded. What the value should be: SessionKey=%14%5e.%2c%5e--%5eXBV*%5b)B%5b.*)BV-)%2bB%5cV-%2c*X*XZ%5c%2b%2c%12 What is returned by the cookie that is set via the EO PDF Options after the convert is called: SessionKey%3D%2514%255e.%252c%255e--%255eXBV*%255b)B%255b.*)BV-)%252bB%255cV-%252c*X*XZ%255c%252b%252c%2512
If you check the values when it is set, they both match. I am guessing that the PDF converter is doing an encoding when it sets the cookie. Please let me know if I am doing something wrong or if this is indeed a bug.
Thanks,
Tom
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,195
|
Hi,
The raw cookie value that is sent from the browser to your web server is ALWAYS encoded. If you use ASP.NET to access the session, it will decode it for you. If you use some other way to access it directly, you may need to decode it yourself. See RFC 2231 for more details.
Thanks!
|
|
Rank: Newbie Groups: Member
Joined: 9/12/2012 Posts: 8
|
Support, Thanks for the reply. I am aware that the cookies is encoded. It appears that it is being double encoded when it is passed through the EO Cookies Option. I created a webpage....webform22.aspx in my case it has two labels on it lbl1 and lbl2. the code behind for webform22.aspx is the following:
Code: C#
public partial class WebForm22 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Request.Cookies.Add(new HttpCookie(Common.SessionManager.gsCookie + "1"));
Request.Cookies[Common.SessionManager.gsCookie + "1"][Common.SessionManager.gsSessionKey + "1"] = "asdf";
}
protected override void OnPreRender(EventArgs e)
{
base.OnPreRender(e);
lbl1.Text = Request.Cookies[Common.SessionManager.gsCookie + "1"].Value.ToString();
lbl2.Text = Request.Cookies[Common.SessionManager.gsCookie].Value.ToString();
}
}
The relevant code in the page that contains the PDF conversion call is:
Code: C#
System.Net.CookieCollection cookies = new System.Net.CookieCollection();
System.Net.Cookie tnp = new System.Net.Cookie();
tnp.Name = Common.SessionManager.gsCookie;
tnp.Path = "/";
tnp.Value = Common.SessionManager.gsSessionKey + "2=asdf";
cookies.Add(tnp);
EO.Pdf.PdfDocument tmpPDF = new EO.Pdf.PdfDocument();
EO.Pdf.HtmlToPdf.Options.Cookies.Add(cookies);
EO.Pdf.HtmlToPdf.ConvertUrl(URL, tmpPDF);
I set a cookie in the page load of webform22.aspx to "asdf" and then display the values of both cookies. The cookie returned from the EO.PDF created cookie has the "=" sign encoded to %3D as if it was encoded by the EO.PDF code. The results that are included in the pdf document are Cookie 1: SessionKey1=asdf Cookie 2: SessionKey2%3Dasdf I still think this might be a bug. Please let me know your thoughts.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,195
|
I see. Thanks for the additional information. We will look into it and get back to you as soon as possible.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,195
|
Hi,
We have posted a new build that should fix this problem. Please see your private message for the download location.
Thanks!
|
|
Rank: Newbie Groups: Member
Joined: 9/12/2012 Posts: 8
|
Thanks. Checking it out now. Will post results shortly.
|
|
Rank: Newbie Groups: Member
Joined: 9/12/2012 Posts: 8
|
Works like champ! Thanks for the quick turnaround on the fix!
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,195
|
You are very welcome. Please let us know if there is anything else.
Thanks!
|
|