This is a migrated thread and some comments may be shown as answers.

Match a string in body using Regex

2 Answers 793 Views
Fiddler Classic
This is a migrated thread and some comments may be shown as answers.
nasekt
Top achievements
Rank 1
nasekt asked on 07 Oct 2014, 07:46 PM

   var bodyString = oSession.GetResponseBodyAsString();
if (oSession.oResponse.MIMEType.Contains("html")) {
var regex = /jimmy/;
if (regex.test(bodyString)) {

oSession.oRequest.FailSession (404, "Blocked", "Fiddler blocked product service request");
}
}

Basically, How do I tell Regex to find the string jimmy present in body, if found, then block the page?

Thank you

2 Answers, 1 is accepted

Sort by
0
Eric Lawrence
Telerik team
answered on 07 Oct 2014, 09:05 PM
Do you actually need a regular expression, or are you simply searching for a string?

if (oSession.oResponse.MIMEType.Contains("html")) {
  oSession.utilDecodeResponse();
  if (
oSession.utilFindInResponse("jimmy", false)>-1)
  {
    //...
  }
}


Regards,
Eric Lawrence
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
nasekt
Top achievements
Rank 1
answered on 07 Oct 2014, 09:32 PM
The problem is,  the Metadata collected from the previous visits gets listed as well, So there are 70-80 identical strings in a given HTML 


 <title>if the title contains the string jimmy, then block the page</title> 

How can I do this with Fiddler?




Tags
Fiddler Classic
Asked by
nasekt
Top achievements
Rank 1
Answers by
Eric Lawrence
Telerik team
nasekt
Top achievements
Rank 1
Share this question
or