setup-cpp/dist/node16/multipart-parser.e63ad71c.js

3 lines
4.5 KiB
JavaScript

var e=("undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{}).parcelRequire810d;e.register("kCYt6",(t,a)=>{var r,n;async function i(e,t){let a,i,o,A,s,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,_=e=>{o+=b.decode(e,{stream:!0})},R=e=>{h.push(e)},f=()=>{let e=new r.File(h,d,{type:s});T.append(A,e)},u=()=>{T.append(A,o)},b=new TextDecoder("utf-8");for await(let t of(b.decode(),l.onPartBegin=()=>{l.onPartData=_,l.onPartEnd=u,a="",i="",o="",A="",s="",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&&(A=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=R,l.onPartEnd=f)}else"content-type"===a&&(s=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("wabHV"),n=e("33Q0z");let o=0,A={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++},s=1,d={PART_BOUNDARY:s,LAST_BOUNDARY:s*=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=A.START_BOUNDARY}write(e){let t,a,r=0,n=e.length,i=this.index,{lookbehind:o,boundary:s,boundaryChars:l,index:D,state:h,flags:T}=this,_=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 A.START_BOUNDARY:if(D===s.length-2){if(45===t)T|=d.LAST_BOUNDARY;else if(13!==t)return;D++;break}if(D-1==s.length-2){if(T&d.LAST_BOUNDARY&&45===t)h=A.END,T=0;else{if(T&d.LAST_BOUNDARY||10!==t)return;D=0,c("onPartBegin"),h=A.HEADER_FIELD_START}break}t!==s[D+2]&&(D=-2),t===s[D+2]&&D++;break;case A.HEADER_FIELD_START:h=A.HEADER_FIELD,u("onHeaderField"),D=0;case A.HEADER_FIELD:if(13===t){b("onHeaderField"),h=A.HEADERS_ALMOST_DONE;break}if(D++,45===t)break;if(58===t){if(1===D)return;H("onHeaderField",!0),h=A.HEADER_VALUE_START;break}if((a=E(t))<97||a>122)return;break;case A.HEADER_VALUE_START:if(32===t)break;u("onHeaderValue"),h=A.HEADER_VALUE;case A.HEADER_VALUE:13===t&&(H("onHeaderValue",!0),c("onHeaderEnd"),h=A.HEADER_VALUE_ALMOST_DONE);break;case A.HEADER_VALUE_ALMOST_DONE:if(10!==t)return;h=A.HEADER_FIELD_START;break;case A.HEADERS_ALMOST_DONE:if(10!==t)return;c("onHeadersEnd"),h=A.PART_DATA_START;break;case A.PART_DATA_START:h=A.PART_DATA,u("onPartData");case A.PART_DATA:if(i=D,0===D){for(r+=R;r<f&&!(e[r]in l);)r+=_;r-=R,t=e[r]}if(D<s.length)s[D]===t?(0===D&&H("onPartData",!0),D++):D=0;else if(D===s.length)D++,13===t?T|=d.PART_BOUNDARY:45===t?T|=d.LAST_BOUNDARY:D=0;else if(D-1===s.length){if(T&d.PART_BOUNDARY){if(D=0,10===t){T&=~d.PART_BOUNDARY,c("onPartEnd"),c("onPartBegin"),h=A.HEADER_FIELD_START;break}}else T&d.LAST_BOUNDARY&&45===t?(c("onPartEnd"),h=A.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",0,i,e),i=0,u("onPartData"),r--}break;case A.END:break;default:throw Error("Unexpected state entered: "+h)}H("onHeaderField"),H("onHeaderValue"),H("onPartData"),this.index=D,this.state=h,this.flags=T}end(){if(this.state===A.HEADER_FIELD_START&&0===this.index||this.state===A.PART_DATA&&this.index===this.boundary.length)this.onPartEnd();else if(this.state!==A.END)throw Error("MultipartParser.end(): stream ended unexpectedly")}}});
//# sourceMappingURL=multipart-parser.e63ad71c.js.map