0

Shopping cart implements exception logging from browser using:

window.onerror = function (errorMsg, url, lineNumber, column, errorObj) {
    $.post('/Home/Error',
    {
        "errorMsg": errorMsg,
        "url": url,
        "lineNumber": lineNumber,
        "column": column,
        "errorobj": JSON.stringify(errorObj)
    });

This logs strange errors about token o :

Error Uncaught SyntaxError: Unexpected token o

This exception occurs 4-8 times again in same second form same IP address. After some time it occurs again in 4-8 times. There are small number of IP addresses from which its occurs. It looks like they are human IP addresses, not robots.

URLs and column numbers vary a bit:

Line 1 Column 2
Line 1 Column 10 Object {}
Line 1 Column 10 Object {}
Line 1 Column 9 Object {}
Line 1 Column 1 Object {}

Line number is 1 always:

object is empty.

There are 4 different column numbers: 1,2,9,10

HTTP headers in error posting request are:

Connection  keep-alive
Content-Length  165
Content-Type    application/x-www-form-urlencoded; charset=UTF-8
Accept  */*
Accept-Encoding gzip, deflate
Accept-Language et-EE,et;q=0.8,en-US;q=0.6,en;q=0.4,de;q=0.2
Cookie  __utma=117734412.255164026.1415001424.1415340483.1417604639.4; __utmz=117734412.1415001424.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); __utma=56901291.1707816279.1415687607.1418885975.1424090658.4; __utmz=56901291.1415687607.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); Eeva_Session=5BA67BC05470AD4E1BA6B3F6
User-Agent  Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.115 Safari/537.36
X-Requested-With    XMLHttpRequest

How to fix or diagnose this exception ? Cart contains no o object probably. First line is <!DOCTYPE html>

User agent part without OS is always mostly the same:

Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.115 Safari/537.36

or

Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.115 Safari/537.36

or

User-Agent Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.71 Safari/537.36

So it looks like it occurs in this particular browser only.

How to fix or diagnose this error so that it does not occur?

ASP.NET MVC4, jQuery, jQuery ui and few common jQuery plugins are used.

Update

Those pages contain few ajax calls. /Store/Browse contains ajax to add item to cart:

   request = $.post('/Store/AddToCart',
        serializedData, function (response) {
            $("#cart-status").text(response.Total);
            $inputs.prop("disabled", false);
            var xx = $form[0].quantity;
            $($form[0].quantity).css("background-color", "green");
            showMessage(response.Message);
            showFadeOutMessage(response.Message);
        })
           .fail(function (jqXHR, textStatus, errorThrown) {
               alert('Viga ' + textStatus);
           })
          .always(function () {
              $inputs.prop("disabled", false);
          });

Store/Detail contains ajax to retrieve images:

  $.get(
            '/Store/Similar?product=TN_8627&category=3',
                  {
                      per_page: per_page,
                      page: page,
                      first: carousel.first,
                      last: carousel.last
                  },
                  function(data) {
                      mycarousel_itemAddCallback(carousel, first, last, data, page);
                  }
              );

error occurs in both pages. JSON.Parse() which can cause this error according to I keep getting "Uncaught SyntaxError: Unexpected token o" answer is not used.

How to fix or diagnose them ?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Andrus
  • 26,339
  • 60
  • 204
  • 378
  • The error may be in the response if the response is JSON. Check via the browser's developer console. – Pointy Mar 02 '15 at 20:01
  • did you see this question? http://stackoverflow.com/questions/8081701/i-keep-getting-uncaught-syntaxerror-unexpected-token-o – Matt Bodily Mar 02 '15 at 20:02
  • @Pointy: this error occurs from customer browser. I cannot reproduce it and have no access to customer browser. – Andrus Mar 02 '15 at 20:04
  • @Pointy Yes, it seems that both pages contain 1-2 ajax calls which return json. I updated question. Pages contain different ajax calls. How to fix or diagnose those ? – Andrus Mar 02 '15 at 20:11
  • One possibility is that the error has to do with customer-supplied data ending up in the response without being properly protected against XSS vulnerabilities. – Pointy Mar 02 '15 at 20:12
  • @MattBodily yes, I read this question. This question points that data was wrong. My data is returned from ASP.NET MVC4 controller, I expect that it is correct. It occurs only few times but those pages are viewed and calls are issued hundreds or thousands of times per day. If I open same pages in my chrome, exception does not occur. In my case exception in not reproducible in my browser. – Andrus Mar 02 '15 at 20:16
  • I'm not sure; it depends on what you can do from your server. If you cannot reproduce the problem it's going to be pretty hard to find, I suspect. – Pointy Mar 02 '15 at 21:56
  • Application code written using ASP.NET MVC4 Server is Mono with Debian. Anything can changed in application code in in html Razor views. – Andrus Mar 02 '15 at 22:36

0 Answers0