asp.netjavascriptregexxmlhttprequestyellow-screen-of-death

YSOD Yellow Screen Of Death JavaScript RegExp - Syntax Error


I built up this regex at http://regextester.com to parse YSOD but VS is complaining about a syntax error. I am sure I am missing an escape somewhere but I am coming up blank.

Here is is in original form. any help is appreciated.

var rxYSOD = /<!--\s*\[(.*?)]:(\s*.*\s(.*\n)*?)\s*(at(.*\n)*)-->/gs;

UPDATE: Kobi pointed out the obvious and got me moving again. For those who are interested, this is valid JavaScript to test and parse an XMLHttpRequest.responseText for an ASP.net Yellow Screen Of Death (YSOD).

var rxYSOD = /<!--\s*\[(.*?)]:(\s*.*\s(.*[\n\r]*)*?)\s*(at(.*[\n\r]*)*)-->/;
if (rxYSOD.test(text)) {
    // looks like one..
    var ysod = rxYSOD.exec(text);
    errObj = { Message: ysod[2], StackTrace: ysod[4], ExceptionType: ysod[1] };
}

@Kobi - This is the result and the reason I want to parse the html even though I get a 500:

{
 "message": " Unknown web method ValidateUser.\r\nParameter name: methodName\r\n",
 "stackTrace": "at System.Web.Script.Services.WebServiceData.GetMethodData(String methodName)\r\n   at System.Web.Script.Services.RestHandler.CreateHandler(WebServiceData webServiceData, String methodName)\r\n   at System.Web.Script.Services.RestHandler.CreateHandler(HttpContext context)\r\n   at System.Web.Script.Services.RestHandlerFactory.GetHandler(HttpContext context, String requestType, String url, String pathTranslated)\r\n   at System.Web.Script.Services.ScriptHandlerFactory.GetHandler(HttpContext context, String requestType, String url, String pathTranslated)\r\n   at System.Web.HttpApplication.MapHttpHandler(HttpContext context, String requestType, VirtualPath path, String pathTranslated, Boolean useAppConfig)\r\n   at System.Web.HttpApplication.MapHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()\r\n   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)\r\n",
 "exceptionType": "ArgumentException",
 "errorObject": {
  "Message": " Unknown web method ValidateUser.\r\nParameter name: methodName\r\n",
  "StackTrace": "at System.Web.Script.Services.WebServiceData.GetMethodData(String methodName)\r\n   at System.Web.Script.Services.RestHandler.CreateHandler(WebServiceData webServiceData, String methodName)\r\n   at System.Web.Script.Services.RestHandler.CreateHandler(HttpContext context)\r\n   at System.Web.Script.Services.RestHandlerFactory.GetHandler(HttpContext context, String requestType, String url, String pathTranslated)\r\n   at System.Web.Script.Services.ScriptHandlerFactory.GetHandler(HttpContext context, String requestType, String url, String pathTranslated)\r\n   at System.Web.HttpApplication.MapHttpHandler(HttpContext context, String requestType, VirtualPath path, String pathTranslated, Boolean useAppConfig)\r\n   at System.Web.HttpApplication.MapHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()\r\n   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)\r\n",
  "ExceptionType": "ArgumentException"
 },
 "statusCode": 500,
 "servicePath": "/Authentication_JSON_AppService.axd",
 "useGet": false,
 "params": {
  "username": "testingUser",
  "password": "testingUser",
  "customCredential": null
 },
 "methodName": "ValidateUser",
 "__typeName": "Salient.ScriptModel.WebServiceError"
}

Solution

  • Firefox says:

    Error: invalid regular expression flag s
    Source Code:
    var rxYSOD = /<!--\s*\[(.*?)]:(\s*.*\s(.*\n)*?)\s*(at(.*\n)*)-->/gs; 
    

    After removing the s it seems ok (of course, it isn't tested, just parsed correctly).