You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There are some errors when handling invalid multipart-data:
TypeError: Cannot read property 'split' of undefined
at _multipartparser (./node_modules/node-simple-router/lib/router.js:354:47)
at IncomingMessage. (./node_modules/node-simple-router/lib/router.js:137:26
......
_multipartparser=function(body,content_type){varboundary,i,len1,m,obj,part,parts,resp;resp={"multipart-data": []};// boundary = content_type.split(/;\s+/)[1].split('=')[1].trim(); // -- the old codeboundary=content_type.split(/;\s+/)[1];if(boundary){boundary=boundary.split('=')[1];if(boundary){boundary=boundary.trim();parts=body.split("--"+boundary);for(i=0,len1=parts.length;i<len1;i++){part=parts[i];if(part&&part.match(/Content-Disposition:/i)){obj={};m=part.match(/Content-Disposition:\s+(.+?);/i);if(m){obj.contentDisposition=m[1];}m=part.match(/name="(.+?)"/i);if(m){obj.fieldName=m[1];}m=part.match(/filename="(.+?)"/i);if(m){obj.fileName=m[1];}m=part.match(/Content-Type:\s+(.+?)\s/i);if(m){obj.fileType=m[1];}else{obj.fileType='text/plain';}m=part.match(/Content-Length:\s+(\d+?)/i);if(m){obj.contentLength=m[1];}m=part.match(/\r\n\r\n/);if(m){obj.fileData=part.slice(m.index+4,-2);obj.fileLen=obj.fileData.length;}resp['multipart-data'].push(obj);}}}}returnresp;};
and the coffee script is:
_multipartparser= (body, content_type) ->resp="multipart-data": []
# boundary = content_type.split(/;\s+/)[1].split('=')[1].trim() #-- the old codeboundary=content_type.split(/;\s+/)[1]
if boundary
boundary=boundary.split('=')[1]
if boundary
boundary=boundary.trim()
parts=body.split("--#{boundary}")
for part in parts
if part andpart.match(/Content-Disposition:/i)
#dispatch.log "PART: #{part}"obj= {}
m=part.match(/Content-Disposition:\s+(.+?);/i)
if m
obj.contentDisposition= m[1]
m=part.match(/name="(.+?)"/i)
if m
obj.fieldName= m[1]
m=part.match(/filename="(.+?)"/i)
if m
obj.fileName= m[1]
m=part.match(/Content-Type:\s+(.+?)\s/i)
if m
obj.fileType= m[1]
elseobj.fileType='text/plain'm=part.match(/Content-Length:\s+(\d+?)/i)
if m
obj.contentLength= m[1]
m=part.match/\r\n\r\n/if m
obj.fileData=part.slice(m.index+4, -2)
obj.fileLen=obj.fileData.length
resp['multipart-data'].push obj
resp
The text was updated successfully, but these errors were encountered:
There are some errors when handling invalid multipart-data:
TypeError: Cannot read property 'split' of undefined
at _multipartparser (./node_modules/node-simple-router/lib/router.js:354:47)
at IncomingMessage. (./node_modules/node-simple-router/lib/router.js:137:26
......
The code at that positon is:
May I modify this code to(javascript):
and the coffee script is:
The text was updated successfully, but these errors were encountered: