setup-cpp/dist/node12/multipart-parser.c03ddc74.js

3 lines
4.5 KiB
JavaScript
Raw Normal View History

2023-05-27 03:00:04 +08:00
var e=("undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{}).parcelRequire810d;e.register("6KsJx",(t,a)=>{var r,n;async function i(e,t){let a,i,o,s,A,d;if(!/multipart/i.test(t))throw TypeError("Failed to fetch");let E=t.match(/boundary=(?:"([^"]+)"|([^;]+))/i);if(!E)throw TypeError("no or bad content-type header, no multipart boundary");let l=new D(E[1]||E[2]),h=[],T=new n.FormData,R=e=>{o+=b.decode(e,{stream:!0})},_=e=>{h.push(e)},f=()=>{let e=new r.File(h,d,{type:A});T.append(s,e)},u=()=>{T.append(s,o)},b=new TextDecoder("utf-8");for await(let t of(b.decode(),l.onPartBegin=()=>{l.onPartData=R,l.onPartEnd=u,a="",i="",o="",s="",A="",d=null,h.length=0},l.onHeaderField=e=>{a+=b.decode(e,{stream:!0})},l.onHeaderValue=e=>{i+=b.decode(e,{stream:!0})},l.onHeaderEnd=()=>{if(i+=b.decode(),"content-disposition"===(a=a.toLowerCase())){let e=i.match(/\bname=("([^"]*)"|([^()<>@,;:\\"/[\]?={}\s\t]+))/i);e&&(s=e[2]||e[3]||""),(d=(e=>{let t=e.match(/\bfilename=("(.*?)"|([^()<>@,;:\\"/[\]?={}\s\t]+))($|;\s)/i);if(!t)return;let a=t[2]||t[3]||"",r=a.slice(a.lastIndexOf("\\")+1);return(r=r.replace(/%22/g,'"')).replace(/&#(\d{4});/g,(e,t)=>String.fromCharCode(t))})(i))&&(l.onPartData=_,l.onPartEnd=f)}else"content-type"===a&&(A=i);i="",a=""},e))l.write(t);return l.end(),T}Object.defineProperty(t.exports,"toFormData",{get:()=>i,set:void 0,enumerable:!0,configurable:!0}),r=e("j9HqM"),n=e("1RVNT");let o=0,s={START_BOUNDARY:o++,HEADER_FIELD_START:o++,HEADER_FIELD:o++,HEADER_VALUE_START:o++,HEADER_VALUE:o++,HEADER_VALUE_ALMOST_DONE:o++,HEADERS_ALMOST_DONE:o++,PART_DATA_START:o++,PART_DATA:o++,END:o++},A=1,d={PART_BOUNDARY:A,LAST_BOUNDARY:A*=2},E=e=>32|e,l=()=>{};class D{constructor(e){this.index=0,this.flags=0,this.onHeaderEnd=l,this.onHeaderField=l,this.onHeadersEnd=l,this.onHeaderValue=l,this.onPartBegin=l,this.onPartData=l,this.onPartEnd=l,this.boundaryChars={},e="\r\n--"+e;let t=new Uint8Array(e.length);for(let a=0;a<e.length;a++)t[a]=e.charCodeAt(a),this.boundaryChars[t[a]]=!0;this.boundary=t,this.lookbehind=new Uint8Array(this.boundary.length+8),this.state=s.START_BOUNDARY}write(e){let t,a,r=0,n=e.length,i=this.index,{lookbehind:o,boundary:A,boundaryChars:l,index:D,state:h,flags:T}=this,R=this.boundary.length,_=R-1,f=e.length,u=e=>{this[e+"Mark"]=r},b=e=>{delete this[e+"Mark"]},c=(e,t,a,r)=>{(void 0===t||t!==a)&&this[e](r&&r.subarray(t,a))},H=(t,a)=>{let n=t+"Mark";n in this&&(a?(c(t,this[n],r,e),delete this[n]):(c(t,this[n],e.length,e),this[n]=0))};for(r=0;n>r;r++)switch(t=e[r],h){case s.START_BOUNDARY:if(D===A.length-2){if(45===t)T|=d.LAST_BOUNDARY;else if(13!==t)return;D++;break}if(D-1==A.length-2){if(T&d.LAST_BOUNDARY&&45===t)h=s.END,T=0;else{if(T&d.LAST_BOUNDARY||10!==t)return;D=0,c("onPartBegin"),h=s.HEADER_FIELD_START}break}t!==A[D+2]&&(D=-2),t===A[D+2]&&D++;break;case s.HEADER_FIELD_START:h=s.HEADER_FIELD,u("onHeaderField"),D=0;case s.HEADER_FIELD:if(13===t){b("onHeaderField"),h=s.HEADERS_ALMOST_DONE;break}if(D++,45===t)break;if(58===t){if(1===D)return;H("onHeaderField",!0),h=s.HEADER_VALUE_START;break}if((a=E(t))<97||a>122)return;break;case s.HEADER_VALUE_START:if(32===t)break;u("onHeaderValue"),h=s.HEADER_VALUE;case s.HEADER_VALUE:13===t&&(H("onHeaderValue",!0),c("onHeaderEnd"),h=s.HEADER_VALUE_ALMOST_DONE);break;case s.HEADER_VALUE_ALMOST_DONE:if(10!==t)return;h=s.HEADER_FIELD_START;break;case s.HEADERS_ALMOST_DONE:if(10!==t)return;c("onHeadersEnd"),h=s.PART_DATA_START;break;case s.PART_DATA_START:h=s.PART_DATA,u("onPartData");case s.PART_DATA:if(i=D,0===D){for(r+=_;r<f&&!(e[r]in l);)r+=R;r-=_,t=e[r]}if(D<A.length)A[D]===t?(0===D&&H("onPartData",!0),D++):D=0;else if(D===A.length)D++,13===t?T|=d.PART_BOUNDARY:45===t?T|=d.LAST_BOUNDARY:D=0;else if(D-1===A.length){if(T&d.PART_BOUNDARY){if(D=0,10===t){T&=~d.PART_BOUNDARY,c("onPartEnd"),c("onPartBegin"),h=s.HEADER_FIELD_START;break}}else T&d.LAST_BOUNDARY&&45===t?(c("onPartEnd"),h=s.END,T=0):D=0}if(D>0)o[D-1]=t;else if(i>0){let e=new Uint8Array(o.buffer,o.byteOffset,o.byteLength);c("onPartData",
//# sourceMappingURL=multipart-parser.c03ddc74.js.map