w3af (1.0-rc3svn3489-1) 10_json-fix.dpatch

Summary

 core/controllers/misc/dependencyCheck.py |    6 +++---
 core/data/fuzzer/fuzzer.py               |    8 ++++----
 core/data/request/frFactory.py           |    6 +++---
 core/data/request/jsonPostDataRequest.py |    8 ++++----
 4 files changed, 14 insertions(+), 14 deletions(-)

    
download this patch

Patch contents

#! /bin/sh /usr/share/dpatch/dpatch-run
## json-fix.dpatch by Bernd Zeimetz <bzed@debian.org>
##
## DP: python-json is not available in Python2.6

@DPATCH@
diff -urNad '--exclude=CVS' '--exclude=.svn' '--exclude=.git' '--exclude=.arch' '--exclude=.hg' '--exclude=_darcs' '--exclude=.bzr' w3af-1.0~rc2svn3429~/core/controllers/misc/dependencyCheck.py w3af-1.0~rc2svn3429/core/controllers/misc/dependencyCheck.py
--- w3af-1.0~rc2svn3429~/core/controllers/misc/dependencyCheck.py      2010-03-06 16:14:46.000000000 +0100
+++ w3af-1.0~rc2svn3429/core/controllers/misc/dependencyCheck.py       2010-05-10 22:48:57.191003428 +0200
@@ -97,10 +97,10 @@
             sys.exit( 1 )
     
     try:
-        from extlib.jsonpy import json as json
-    except:
+        import json
+    except ImportError:
         try:
-            import json
+            import simplejson as json
         except:
             print 'You have to install python-json lib. Debian based distributions: apt-get install python-json'
             sys.exit( 1 )
diff -urNad '--exclude=CVS' '--exclude=.svn' '--exclude=.git' '--exclude=.arch' '--exclude=.hg' '--exclude=_darcs' '--exclude=.bzr' w3af-1.0~rc2svn3429~/core/data/fuzzer/fuzzer.py w3af-1.0~rc2svn3429/core/data/fuzzer/fuzzer.py
--- w3af-1.0~rc2svn3429~/core/data/fuzzer/fuzzer.py    2010-03-06 16:14:48.000000000 +0100
+++ w3af-1.0~rc2svn3429/core/data/fuzzer/fuzzer.py     2010-05-10 22:48:57.192000714 +0200
@@ -38,9 +38,9 @@
 from core.data.dc.cookie import cookie as cookie
 from core.data.dc.dataContainer import dataContainer as dc
 try:
-    from extlib.jsonpy import json as json
-except:
     import json
+except ImportError:
+    import simplejson as json
 from core.data.request.httpPostDataRequest import httpPostDataRequest
 from core.data.request.httpQsRequest import httpQsRequest
 
@@ -210,7 +210,7 @@
     
     # Now, fuzz the parsed JSON data...
     postdata = freq.getData()
-    jsonPostData = json.read( postdata )
+    jsonPostData = json.loads( postdata )
     return _makeMutants( freq, mutantClass, mutant_str_list, fuzzableParamList , append, jsonPostData )
 
 def isJSON( freq ):
@@ -222,7 +222,7 @@
         # We have something that's not URL encoded in the postdata, it could be something
         # like JSON, XML, or multipart encoding. Let's try with JSON
         try:
-            jsonPostData = json.read( postdata )
+            jsonPostData = json.loads( postdata )
         except:
             # It's not json, maybe XML or multipart, I don't really care ( at least not in this section of the code )
             return False
diff -urNad '--exclude=CVS' '--exclude=.svn' '--exclude=.git' '--exclude=.arch' '--exclude=.hg' '--exclude=_darcs' '--exclude=.bzr' w3af-1.0~rc2svn3429~/core/data/request/frFactory.py w3af-1.0~rc2svn3429/core/data/request/frFactory.py
--- w3af-1.0~rc2svn3429~/core/data/request/frFactory.py        2010-03-06 16:14:48.000000000 +0100
+++ w3af-1.0~rc2svn3429/core/data/request/frFactory.py 2010-05-10 22:48:57.192000714 +0200
@@ -37,9 +37,9 @@
 
 # for json
 try:
-    from extlib.jsonpy import json as json
-except:
     import json
+except ImportError:
+    import simplejson as json
 
 from core.controllers.w3afException import w3afException
 import core.controllers.outputManager as om
@@ -200,7 +200,7 @@
         #   Case #2, JSON request
         #
         try:
-            dc = json.read( postData )
+            dc = json.loads( postData )
         except:
             pass
         else:
diff -urNad '--exclude=CVS' '--exclude=.svn' '--exclude=.git' '--exclude=.arch' '--exclude=.hg' '--exclude=_darcs' '--exclude=.bzr' w3af-1.0~rc2svn3429~/core/data/request/jsonPostDataRequest.py w3af-1.0~rc2svn3429/core/data/request/jsonPostDataRequest.py
--- w3af-1.0~rc2svn3429~/core/data/request/jsonPostDataRequest.py      2009-11-26 00:09:09.000000000 +0100
+++ w3af-1.0~rc2svn3429/core/data/request/jsonPostDataRequest.py       2010-05-10 22:48:57.193000724 +0200
@@ -25,9 +25,9 @@
 from core.data.request.httpPostDataRequest import httpPostDataRequest
 import core.data.dc.dataContainer as dc
 try:
-    from extlib.jsonpy import json as json
-except:
     import json
+except ImportError:
+    import simplejson as json
 
 class jsonPostDataRequest(httpPostDataRequest):
     '''
@@ -43,7 +43,7 @@
         '''
         @return: A string that represents the JSON data saved in the dc.
         '''
-        res = json.write(self._dc)
+        res = json.dumps(self._dc)
         return res
         
     def __str__( self ):
@@ -54,7 +54,7 @@
         strRes += self._url
         strRes += ' | Method: ' + self._method
         strRes += ' | JSON: ('
-        strRes += json.write(self._dc)
+        strRes += json.dumps(self._dc)
         strRes += ')'
         return strRes