Converting Numeric Values from Query String

Issue #14411309 • Assigned to James M.

Details

Author
Mike C.
Created
Oct 27, 2017
Privacy
This issue is public.
Found in
  • Microsoft Edge
Reports
Reported by 1 person

Sign in to watch or report this issue.

Steps to reproduce

I am trying to pass a date through the query string into a mvc project.
when in the c# code executing my ActionResult for the page load I am pulling the date out and attempting to parse into a datetime. Workds fine in FF and Chrome, but not Edge. When I give up and split the date, (“10/27/2017”), into an array of strings then try to parse this into an int, I get invalid format error when running Edge but works in FF and Chrome.

string[] TempStartDate = StartDate.Split(‘/’);
string[] TempEndDate = EndDate.Split(‘/’);

            int sMonth = int.Parse(TempStartDate[0]); //'Input string was not in a correct format'  however the string being passed in is "10"
            int sDay = int.Parse(TempStartDate[1]);
            int sYear = int.Parse(TempStartDate[2]);

            int eMonth = int.Parse(TempEndDate[0]);
            int eDay = int.Parse(TempEndDate[1]);
            int eYear = int.Parse(TempEndDate[2]);


            PeriodDates[0] = new DateTime(sYear, sMonth, sDay);
            PeriodDates[1] = new DateTime(eYear, eMonth, eDay);

Attachments

0 attachments

    Comments and activity

    • the url looks like this
      …?hostname=All%20Hosts&period=custom&startdate=%E2%80%8E10%E2%80%8E/%E2%80%8E16%E2%80%8E/%E2%80%8E2017&enddate=%E2%80%8E10%E2%80%8E/%E2%80%8E25%E2%80%8E/%E2%80%8E2017

    • turns out I have to
      EndDate = Regex.Replace(EndDate, @"[^\u0000-\u007F]+", string.Empty);
      on query string values for edge.

    • Microsoft Edge Team

      Changed Assigned To to “Steven K.”

    • Hi Mike,

      I am curious about the source of those date strings.  What you are seeing is the UTF-8 encoding for the LEFT-TO-RIGHT MARK.  E2 80 8E

      I believe this mark is normally used for elements in a web page to specify the direction via UTF-8, which I believe is also deprecated by the HTML <bdi> tag.

      Your regular expression is a work around for this because it is removing all of the unicode characters outside of the lower range which this mark is.  The unicode character is represented as "\u200E".

      http://www.fileformat.info/info/unicode/char/200e/index.htm

      Can you give me more information on where this string originated from and also how you are using C# with Edge, I.e. information on your MVC application?

      Once I get more information from you on how you are using this code, I will investigate why the code without the workaround does not work in Edge but does work in other browsers.

      Appreciate the submission,

      Steve

    • The URL is built here in JS in the view.
      function reloadPage(hostname, period,sDate,eDate) {
      window.location.href = “/ClientBehaviour/PotentialClients?hostname” +
      encodeURI(“=” + hostname + “&period=” + period + “&startdate=” +
      sDate + “&enddate=” + eDate);

      The bits needed are pull out of the query string in the controller here:
      string TargetHostName = Request.QueryString[“hostname”];
      TargetHostName = TargetHostName == null ? “All Hosts” : TargetHostName;
      string TargetPeriod = Request.QueryString[“period”];
      TargetPeriod = TargetPeriod == null ? “yesterday” : TargetPeriod;
      string StartDate = Request.QueryString[“startdate”];
      string EndDate = Request.QueryString[“enddate”];

      Again, all this works with no issue on FF and Chrome, haven’t tested on Opera or Safari.

      Thank you for your help.

      Mike

    • Microsoft Edge Team

      Changed Assigned To from “Steven K.” to “James M.”

    You need to sign in to your Microsoft account to add a comment.

    Sign in