[{"data":1,"prerenderedAt":2085},["ShallowReactive",2],{"\u002Farticles\u002Foss-filename-url-encoding":3},{"id":4,"title":5,"body":6,"date":2069,"description":2070,"extension":2071,"head":2072,"image":2073,"meta":2074,"navigation":412,"ogImage":2072,"path":2075,"rating":2076,"readingTime":2077,"robots":2072,"schemaOrg":2072,"seo":2078,"sitemap":2079,"stem":2080,"tags":2081,"__hash__":2084},"articles_en\u002Farticles\u002Foss-filename-url-encoding.md","Special Characters in OSS Filenames: URL-Encoding Pitfalls and the Real Fix",{"type":7,"value":8,"toc":2039},"minimark",[9,32,37,49,52,99,109,136,139,143,149,154,170,186,192,200,209,268,294,310,314,339,343,364,442,466,475,483,490,525,547,618,630,642,646,663,1097,1119,1123,1141,1190,1209,1217,1220,1275,1295,1298,1376,1380,1390,1445,1449,1452,1502,1542,1550,1554,1579,1587,1618,1621,1658,1662,1673,1756,1769,1789,1800,1804,1828,1831,1835,1860,1864,1964,1968,1985,1988,1992,2035],[10,11,12,29],"note",{},[13,14,15,16,20,21,24,25,28],"p",{},"In production, a user uploaded a file called ",[17,18,19],"code",{},"Product Doc_问题+答案.docx",". The upload succeeded and the file showed up in the list, but clicking preview got nowhere: the spinner turned for a long time and then the pane stayed blank. The backend endpoint that reads the file for further processing simply threw back ",[17,22,23],{},"500 Parsing failed",". At the end of the investigation, the culprit turned out to be that innocent-looking ",[17,26,27],{},"+"," in the filename.",[13,30,31],{},"This post is a full post-mortem: from symptom to root cause, from \"treating the symptom\" to \"curing the disease\", plus several deep URL-encoding pits I fell into along the way. All of it is hands-on experience you can carry straight into your own project.",[33,34,36],"h2",{"id":35},"_1-background-a-file-upload-system","1. Background: a file upload system",[13,38,39,40,44,45,48],{},"This is a typical ",[41,42,43],"strong",{},"file management system",": users upload documents (PDF \u002F DOCX \u002F XLSX…) to object storage (OSS), and the file is then registered in the business database. If \"backend processing\" is checked, the server ",[41,46,47],{},"fetches the file's URL, then reads and parses its content for further processing",".",[13,50,51],{},"The data flow looks roughly like this:",[53,54,59],"pre",{"className":55,"code":56,"language":57,"meta":58,"style":58},"language-mermaid shiki shiki-themes github-light github-dark github-dark","flowchart LR\n    A[\"Pick a file\u003Cbr>in the frontend\"] --> B[\"Upload to OSS\u003Cbr>returns file_url\"]\n    B --> C[\"Register API insert\u003Cbr>writes document_url\"]\n    C --> D[(\"Business DB\")]\n    D --> E[\"Backend fetches content\u003Cbr>by document_url to process it\"]\n    D --> F[\"List \u002F detail page\u003Cbr>preview & download\"]\n","mermaid","",[17,60,61,69,75,81,87,93],{"__ignoreMap":58},[62,63,66],"span",{"class":64,"line":65},"line",1,[62,67,68],{},"flowchart LR\n",[62,70,72],{"class":64,"line":71},2,[62,73,74],{},"    A[\"Pick a file\u003Cbr>in the frontend\"] --> B[\"Upload to OSS\u003Cbr>returns file_url\"]\n",[62,76,78],{"class":64,"line":77},3,[62,79,80],{},"    B --> C[\"Register API insert\u003Cbr>writes document_url\"]\n",[62,82,84],{"class":64,"line":83},4,[62,85,86],{},"    C --> D[(\"Business DB\")]\n",[62,88,90],{"class":64,"line":89},5,[62,91,92],{},"    D --> E[\"Backend fetches content\u003Cbr>by document_url to process it\"]\n",[62,94,96],{"class":64,"line":95},6,[62,97,98],{},"    D --> F[\"List \u002F detail page\u003Cbr>preview & download\"]\n",[13,100,101,102,108],{},"Note one key fact: ",[41,103,104,107],{},[17,105,106],{},"document_url"," is not just for browser preview",". It has at least three consumers:",[110,111,112,120,130],"ol",{},[113,114,115,116,119],"li",{},"Browser ",[41,117,118],{},"preview"," (PDFs go straight into an iframe; Office documents go through an online preview service);",[113,121,115,122,125,126,129],{},[41,123,124],{},"download"," (",[17,127,128],{},"window.open",");",[113,131,132,135],{},[41,133,134],{},"Backend fetch for processing"," (the server sends an HTTP request to pull the file content).",[13,137,138],{},"Keep this in mind. The whole \"why fixing only the frontend doesn't work\" part later depends on it.",[33,140,142],{"id":141},"_2-symptom-upload-succeeds-access-returns-404","2. Symptom: upload succeeds, access returns 404",[13,144,145,146,148],{},"The user uploads ",[17,147,19],{},", and OSS returns an access URL that looks like this:",[13,150,151],{},[17,152,153],{},"https:\u002F\u002Fcdn.example.com\u002Ffiles\u002F2026\u002F06\u002F27\u002FProduct Doc_问题+答案.docx",[13,155,156,157,160,161,164,165,48],{},"This filename hits three kinds of \"special characters\" at once: a ",[41,158,159],{},"space",", ",[41,162,163],{},"Chinese characters",", and a ",[41,166,167,168],{},"plus sign ",[17,169,27],{},[13,171,172,173,179,180,182,183,185],{},"Testing gave a strange picture: ",[41,174,175,176,178],{},"the vast majority of files with spaces or Chinese characters worked fine; only the ones with ",[17,177,27],{}," wouldn't open."," The backend read-and-process endpoint also returned ",[17,181,23],{}," for every one of those files. Spaces and Chinese are fine, but ",[17,184,27],{}," is not, and that is exactly the lead to follow.",[33,187,189,190],{"id":188},"_3-digging-for-the-root-cause-the-dual-identity-of","3. Digging for the root cause: the \"dual identity\" of ",[17,191,27],{},[193,194,196,197,199],"h3",{"id":195},"_31-what-does-actually-mean-in-a-url","3.1 What does ",[17,198,27],{}," actually mean in a URL?",[13,201,202,204,205,208],{},[17,203,27],{}," has ",[41,206,207],{},"two contradictory meanings"," in a URL, depending on where it sits and who parses it:",[210,211,212,230],"table",{},[213,214,215],"thead",{},[216,217,218,222,227],"tr",{},[219,220,221],"th",{},"Context",[219,223,224,225],{},"Meaning of ",[17,226,27],{},[219,228,229],{},"Source",[231,232,233,247],"tbody",{},[216,234,235,239,244],{},[236,237,238],"td",{},"application\u002Fx-www-form-urlencoded (forms \u002F query string)",[236,240,241],{},[41,242,243],{},"A space",[236,245,246],{},"The HTML form encoding convention, carried into today's URL standard",[216,248,249,256,265],{},[236,250,251,252,255],{},"The ",[41,253,254],{},"path"," part of the generic URI syntax",[236,257,258,261,262,264],{},[41,259,260],{},"A literal plus sign"," ",[17,263,27],{}," (a reserved character in sub-delims)",[236,266,267],{},"RFC 3986 §2.2",[13,269,270,271,273,274,277,278,281,282,284,285,287,288,48],{},"According to RFC 3986, a ",[17,272,27],{}," in the path should be a ",[41,275,276],{},"literal plus",", and a space is what gets encoded as ",[17,279,280],{},"%20",". The historical baggage is that form submissions encode spaces as ",[17,283,27],{}," (to save bytes and avoid ",[17,286,280],{},"), and the habit is so deeply ingrained that ",[41,289,290,291,293],{},"many servers, gateways and CDNs also treat ",[17,292,27],{}," as a space when parsing the path",[295,296,297],"blockquote",{},[13,298,299,300,302,303,306,307,309],{},"In one sentence: ",[17,301,27],{}," in the query = a space; in the path it ",[41,304,305],{},"should"," = a literal plus, but many servers don't play by the rules and decode a ",[17,308,27],{}," in the path into a space as well.",[193,311,313],{"id":312},"_32-how-oss-loses-the-file","3.2 How OSS \"loses\" the file",[13,315,316,317,320,321,323,324,327,328,331,332,335,336,48],{},"An OSS object key is essentially just a string of bytes. On access, the whole key serves as the path, and the server URL-decodes the path once to restore the real key before looking it up. When the browser requests ",[17,318,319],{},"...\u002FProduct Doc_问题+答案.docx",", OSS decodes the ",[17,322,27],{}," in the path into a space, so the key it actually looks for becomes ",[17,325,326],{},"Product Doc_问题 答案.docx"," (a space, not a plus, between ",[17,329,330],{},"问题"," and ",[17,333,334],{},"答案","). That doesn't match the real key → ",[41,337,338],{},"NoSuchKey → 404 → the file won't open",[193,340,342],{"id":341},"_33-nailing-it-down-with-curl-turning-a-guess-into-proof","3.3 Nailing it down with curl (turning a guess into proof)",[13,344,345,346,349,350,353,354,356,357,359,360,363],{},"Go straight to ",[17,347,348],{},"curl -I"," (send only a HEAD request to see the status code, without downloading the body). Change ",[41,351,352],{},"only"," the ",[17,355,27],{}," in the filename, once as a bare ",[17,358,27],{}," and once as ",[17,361,362],{},"%2B",", with every other character encoded normally:",[53,365,369],{"className":366,"code":367,"language":368,"meta":58,"style":58},"language-bash shiki shiki-themes github-light github-dark github-dark","# Bare + version (everything else encoded, only + left as is)\ncurl -sI -o \u002Fdev\u002Fnull -w \"%{http_code} \" 'https:\u002F\u002Fcdn.example.com\u002Ffiles\u002F2026\u002F06\u002F27\u002FProduct%20Doc_%E9%97%AE%E9%A2%98+%E7%AD%94%E6%A1%88.docx'\n# → 404\n\n# Encoded version (+ → %2B)\ncurl -sI -o \u002Fdev\u002Fnull -w \"%{http_code} \" 'https:\u002F\u002Fcdn.example.com\u002Ffiles\u002F2026\u002F06\u002F27\u002FProduct%20Doc_%E9%97%AE%E9%A2%98%2B%E7%AD%94%E6%A1%88.docx'\n# → 200\n","bash",[17,370,371,377,403,408,414,419,436],{"__ignoreMap":58},[62,372,373],{"class":64,"line":65},[62,374,376],{"class":375},"sCsY4","# Bare + version (everything else encoded, only + left as is)\n",[62,378,379,383,387,390,394,397,400],{"class":64,"line":71},[62,380,382],{"class":381},"shcOC","curl",[62,384,386],{"class":385},"suiK_"," -sI",[62,388,389],{"class":385}," -o",[62,391,393],{"class":392},"sfrk1"," \u002Fdev\u002Fnull",[62,395,396],{"class":385}," -w",[62,398,399],{"class":392}," \"%{http_code} \"",[62,401,402],{"class":392}," 'https:\u002F\u002Fcdn.example.com\u002Ffiles\u002F2026\u002F06\u002F27\u002FProduct%20Doc_%E9%97%AE%E9%A2%98+%E7%AD%94%E6%A1%88.docx'\n",[62,404,405],{"class":64,"line":77},[62,406,407],{"class":375},"# → 404\n",[62,409,410],{"class":64,"line":83},[62,411,413],{"emptyLinePlaceholder":412},true,"\n",[62,415,416],{"class":64,"line":89},[62,417,418],{"class":375},"# Encoded version (+ → %2B)\n",[62,420,421,423,425,427,429,431,433],{"class":64,"line":95},[62,422,382],{"class":381},[62,424,386],{"class":385},[62,426,389],{"class":385},[62,428,393],{"class":392},[62,430,396],{"class":385},[62,432,399],{"class":392},[62,434,435],{"class":392}," 'https:\u002F\u002Fcdn.example.com\u002Ffiles\u002F2026\u002F06\u002F27\u002FProduct%20Doc_%E9%97%AE%E9%A2%98%2B%E7%AD%94%E6%A1%88.docx'\n",[62,437,439],{"class":64,"line":438},7,[62,440,441],{"class":375},"# → 200\n",[13,443,444,453,454,456,457,459,460,462,463,465],{},[41,445,446,447,449,450,452],{},"Bare ",[17,448,27],{}," → 404, ",[17,451,362],{}," → 200."," The ",[17,455,27],{}," is the only variable, so the causality is pinned down. It also proves in passing that the key stored in OSS really does contain a literal ",[17,458,27],{}," (send ",[17,461,362],{}," in the request, OSS decodes it back to ",[17,464,27],{},", and the lookup hits).",[467,468,469],"tip",{},[13,470,471,472,474],{},"A debugging method: use ",[17,473,348],{}," to decouple \"storage-layer reachability\" from \"upper-layer rendering \u002F preview\". A 200 means file access is fine, so go look at the preview logic; only a 404 \u002F 403 points to a storage or encoding problem. Don't start by staring at the preview component in a debugger.",[33,476,478,479,482],{"id":477},"_4-why-does-it-still-slip-through-when-its-clearly-encoded-the-encodeuri-trap","4. Why does it still slip through when \"it's clearly encoded\"? The ",[17,480,481],{},"encodeURI"," trap",[13,484,485,486,489],{},"The code actually ",[41,487,488],{},"did encode already",":",[53,491,495],{"className":492,"code":493,"language":494,"meta":58,"style":58},"language-ts shiki shiki-themes github-light github-dark github-dark","const encodedUrl = computed(() => encodeURI(documentUrl.value));\n","ts",[17,496,497],{"__ignoreMap":58},[62,498,499,503,506,509,512,516,519,522],{"class":64,"line":65},[62,500,502],{"class":501},"so5gQ","const",[62,504,505],{"class":385}," encodedUrl",[62,507,508],{"class":501}," =",[62,510,511],{"class":381}," computed",[62,513,515],{"class":514},"slsVL","(() ",[62,517,518],{"class":501},"=>",[62,520,521],{"class":381}," encodeURI",[62,523,524],{"class":514},"(documentUrl.value));\n",[13,526,527,529,530,532,533,536,537,543,544,489],{},[17,528,481],{}," handles spaces (→ ",[17,531,280],{},") and Chinese characters (→ ",[17,534,535],{},"%xx","), which is why filenames with spaces or Chinese worked. ",[41,538,539,540,542],{},"But ",[17,541,27],{}," is precisely what it does not encode."," This is the classic difference between it and ",[17,545,546],{},"encodeURIComponent",[210,548,549,568],{},[213,550,551],{},[216,552,553,556,559,565],{},[219,554,555],{},"Function",[219,557,558],{},"Characters left unencoded",[219,560,561,562,564],{},"Encodes ",[17,563,27],{},"?",[219,566,567],{},"Intended use",[231,569,570,597],{},[216,571,572,576,585,591],{},[236,573,574],{},[17,575,481],{},[236,577,578,581,582],{},[17,579,580],{},"A-Za-z0-9 - _ . ! ~ * ' ( )",", plus ",[17,583,584],{},"; , \u002F ? : @ & = + $ #",[236,586,587,588],{},"❌ ",[41,589,590],{},"No",[236,592,593,594],{},"Encoding a \"whole URL\", preserving structural characters such as ",[17,595,596],{},"\u002F : ? #",[216,598,599,603,607,615],{},[236,600,601],{},[17,602,546],{},[236,604,605],{},[17,606,580],{},[236,608,609,610],{},"✅ ",[41,611,612,613],{},"Encodes it as ",[17,614,362],{},[236,616,617],{},"Encoding \"one piece of a URL\", escaping structural characters too",[13,619,620,622,623,626,627,629],{},[17,621,481],{}," preserves structurally meaningful characters like ",[17,624,625],{},"+ \u002F : ? # & ="," as the \"skeleton of the URL\". That is right for encoding a whole URL, but wrong for encoding a filename: a ",[17,628,27],{}," in a filename is data, not structure.",[631,632,633],"warning",{},[13,634,635,636,638,639,641],{},"Conclusion: to encode a filename (one segment of the path), use ",[17,637,546],{},", not ",[17,640,481],{},". This trap is the best hidden of all, because it \"looks fine\" for spaces and Chinese characters and tricks you into believing the encoding is correct.",[33,643,645],{"id":644},"_5-the-first-fix-a-utility-function-replacing-the-read-paths","5. The first fix: a utility function + replacing the \"read\" paths",[13,647,648,649,655,656,659,660,662],{},"The idea: ",[41,650,651,652,654],{},"apply ",[17,653,546],{}," to every segment of the path",", segment by segment (",[17,657,658],{},"\u002F"," must not be encoded, so split on ",[17,661,658],{},", encode each segment, then join them back):",[53,664,666],{"className":492,"code":665,"language":494,"meta":58,"style":58},"\u002F\u002F Encode the \"unencoded\" OSS file URL returned by the backend into a form that is safe to access.\nexport const encodeOssUrl = (raw: string): string => {\n  if (!raw) return \"\";\n  const qIdx = raw.indexOf(\"?\");\n  const query = qIdx >= 0 ? raw.slice(qIdx) : \"\";       \u002F\u002F keep the query (signature etc.) as is\n  const noQuery = qIdx >= 0 ? raw.slice(0, qIdx) : raw;\n  const schemeEnd = noQuery.indexOf(\":\u002F\u002F\");\n  const pathStart = schemeEnd >= 0 ? noQuery.indexOf(\"\u002F\", schemeEnd + 3) : -1;\n  if (pathStart \u003C 0) return raw;\n  const origin = noQuery.slice(0, pathStart);\n  const encodedPath = noQuery\n    .slice(pathStart)\n    .split(\"\u002F\")\n    .map(seg => {\n      let s = seg;\n      try { s = decodeURIComponent(seg); } catch { \u002F* illegal escapes such as a bare %: keep as is *\u002F }\n      return encodeURIComponent(s);\n    })\n    .join(\"\u002F\");\n  return origin + encodedPath + query;\n};\n",[17,667,668,673,710,732,757,796,830,851,900,919,940,953,964,979,996,1011,1040,1052,1058,1072,1091],{"__ignoreMap":58},[62,669,670],{"class":64,"line":65},[62,671,672],{"class":375},"\u002F\u002F Encode the \"unencoded\" OSS file URL returned by the backend into a form that is safe to access.\n",[62,674,675,678,681,684,686,688,692,694,697,700,702,704,707],{"class":64,"line":71},[62,676,677],{"class":501},"export",[62,679,680],{"class":501}," const",[62,682,683],{"class":381}," encodeOssUrl",[62,685,508],{"class":501},[62,687,125],{"class":514},[62,689,691],{"class":690},"sQHwn","raw",[62,693,489],{"class":501},[62,695,696],{"class":385}," string",[62,698,699],{"class":514},")",[62,701,489],{"class":501},[62,703,696],{"class":385},[62,705,706],{"class":501}," =>",[62,708,709],{"class":514}," {\n",[62,711,712,715,717,720,723,726,729],{"class":64,"line":77},[62,713,714],{"class":501},"  if",[62,716,125],{"class":514},[62,718,719],{"class":501},"!",[62,721,722],{"class":514},"raw) ",[62,724,725],{"class":501},"return",[62,727,728],{"class":392}," \"\"",[62,730,731],{"class":514},";\n",[62,733,734,737,740,742,745,748,751,754],{"class":64,"line":83},[62,735,736],{"class":501},"  const",[62,738,739],{"class":385}," qIdx",[62,741,508],{"class":501},[62,743,744],{"class":514}," raw.",[62,746,747],{"class":381},"indexOf",[62,749,750],{"class":514},"(",[62,752,753],{"class":392},"\"?\"",[62,755,756],{"class":514},");\n",[62,758,759,761,764,766,769,772,775,778,780,783,786,788,790,793],{"class":64,"line":89},[62,760,736],{"class":501},[62,762,763],{"class":385}," query",[62,765,508],{"class":501},[62,767,768],{"class":514}," qIdx ",[62,770,771],{"class":501},">=",[62,773,774],{"class":385}," 0",[62,776,777],{"class":501}," ?",[62,779,744],{"class":514},[62,781,782],{"class":381},"slice",[62,784,785],{"class":514},"(qIdx) ",[62,787,489],{"class":501},[62,789,728],{"class":392},[62,791,792],{"class":514},";       ",[62,794,795],{"class":375},"\u002F\u002F keep the query (signature etc.) as is\n",[62,797,798,800,803,805,807,809,811,813,815,817,819,822,825,827],{"class":64,"line":95},[62,799,736],{"class":501},[62,801,802],{"class":385}," noQuery",[62,804,508],{"class":501},[62,806,768],{"class":514},[62,808,771],{"class":501},[62,810,774],{"class":385},[62,812,777],{"class":501},[62,814,744],{"class":514},[62,816,782],{"class":381},[62,818,750],{"class":514},[62,820,821],{"class":385},"0",[62,823,824],{"class":514},", qIdx) ",[62,826,489],{"class":501},[62,828,829],{"class":514}," raw;\n",[62,831,832,834,837,839,842,844,846,849],{"class":64,"line":438},[62,833,736],{"class":501},[62,835,836],{"class":385}," schemeEnd",[62,838,508],{"class":501},[62,840,841],{"class":514}," noQuery.",[62,843,747],{"class":381},[62,845,750],{"class":514},[62,847,848],{"class":392},"\":\u002F\u002F\"",[62,850,756],{"class":514},[62,852,854,856,859,861,864,866,868,870,872,874,876,879,882,884,887,890,892,895,898],{"class":64,"line":853},8,[62,855,736],{"class":501},[62,857,858],{"class":385}," pathStart",[62,860,508],{"class":501},[62,862,863],{"class":514}," schemeEnd ",[62,865,771],{"class":501},[62,867,774],{"class":385},[62,869,777],{"class":501},[62,871,841],{"class":514},[62,873,747],{"class":381},[62,875,750],{"class":514},[62,877,878],{"class":392},"\"\u002F\"",[62,880,881],{"class":514},", schemeEnd ",[62,883,27],{"class":501},[62,885,886],{"class":385}," 3",[62,888,889],{"class":514},") ",[62,891,489],{"class":501},[62,893,894],{"class":501}," -",[62,896,897],{"class":385},"1",[62,899,731],{"class":514},[62,901,903,905,908,911,913,915,917],{"class":64,"line":902},9,[62,904,714],{"class":501},[62,906,907],{"class":514}," (pathStart ",[62,909,910],{"class":501},"\u003C",[62,912,774],{"class":385},[62,914,889],{"class":514},[62,916,725],{"class":501},[62,918,829],{"class":514},[62,920,922,924,927,929,931,933,935,937],{"class":64,"line":921},10,[62,923,736],{"class":501},[62,925,926],{"class":385}," origin",[62,928,508],{"class":501},[62,930,841],{"class":514},[62,932,782],{"class":381},[62,934,750],{"class":514},[62,936,821],{"class":385},[62,938,939],{"class":514},", pathStart);\n",[62,941,943,945,948,950],{"class":64,"line":942},11,[62,944,736],{"class":501},[62,946,947],{"class":385}," encodedPath",[62,949,508],{"class":501},[62,951,952],{"class":514}," noQuery\n",[62,954,956,959,961],{"class":64,"line":955},12,[62,957,958],{"class":514},"    .",[62,960,782],{"class":381},[62,962,963],{"class":514},"(pathStart)\n",[62,965,967,969,972,974,976],{"class":64,"line":966},13,[62,968,958],{"class":514},[62,970,971],{"class":381},"split",[62,973,750],{"class":514},[62,975,878],{"class":392},[62,977,978],{"class":514},")\n",[62,980,982,984,987,989,992,994],{"class":64,"line":981},14,[62,983,958],{"class":514},[62,985,986],{"class":381},"map",[62,988,750],{"class":514},[62,990,991],{"class":690},"seg",[62,993,706],{"class":501},[62,995,709],{"class":514},[62,997,999,1002,1005,1008],{"class":64,"line":998},15,[62,1000,1001],{"class":501},"      let",[62,1003,1004],{"class":514}," s ",[62,1006,1007],{"class":501},"=",[62,1009,1010],{"class":514}," seg;\n",[62,1012,1014,1017,1020,1022,1025,1028,1031,1034,1037],{"class":64,"line":1013},16,[62,1015,1016],{"class":501},"      try",[62,1018,1019],{"class":514}," { s ",[62,1021,1007],{"class":501},[62,1023,1024],{"class":381}," decodeURIComponent",[62,1026,1027],{"class":514},"(seg); } ",[62,1029,1030],{"class":501},"catch",[62,1032,1033],{"class":514}," { ",[62,1035,1036],{"class":375},"\u002F* illegal escapes such as a bare %: keep as is *\u002F",[62,1038,1039],{"class":514}," }\n",[62,1041,1043,1046,1049],{"class":64,"line":1042},17,[62,1044,1045],{"class":501},"      return",[62,1047,1048],{"class":381}," encodeURIComponent",[62,1050,1051],{"class":514},"(s);\n",[62,1053,1055],{"class":64,"line":1054},18,[62,1056,1057],{"class":514},"    })\n",[62,1059,1061,1063,1066,1068,1070],{"class":64,"line":1060},19,[62,1062,958],{"class":514},[62,1064,1065],{"class":381},"join",[62,1067,750],{"class":514},[62,1069,878],{"class":392},[62,1071,756],{"class":514},[62,1073,1075,1078,1081,1083,1086,1088],{"class":64,"line":1074},20,[62,1076,1077],{"class":501},"  return",[62,1079,1080],{"class":514}," origin ",[62,1082,27],{"class":501},[62,1084,1085],{"class":514}," encodedPath ",[62,1087,27],{"class":501},[62,1089,1090],{"class":514}," query;\n",[62,1092,1094],{"class":64,"line":1093},21,[62,1095,1096],{"class":514},"};\n",[13,1098,1099,1100,1103,1104,1107,1108,1113,1114,48],{},"I replaced ",[17,1101,1102],{},"encodeURI(...)"," with ",[17,1105,1106],{},"encodeOssUrl(...)"," in the preview and download call sites. ",[41,1109,1110,1111,719],{},"Self-test: preview and download both worked for files with ",[17,1112,27],{}," …and I thought I was done. But the backend read-and-process endpoint was ",[41,1115,1116,1117],{},"still returning ",[17,1118,23],{},[33,1120,1122],{"id":1121},"_6-the-real-root-the-read-side-and-the-write-side-must-agree","6. The real root: the read side and the write side must agree",[13,1124,1125,1126,1129,1130,1132,1133,1136,1137,1140],{},"The first version only fixed the ",[41,1127,1128],{},"\"read\" paths",", but ",[17,1131,106],{}," has one more consumer the frontend can't reach: ",[41,1134,1135],{},"the backend fetch",". What decides whether the backend can fetch the file is ",[41,1138,1139],{},"the value written into the database",". The register API had been receiving the bare URL all along:",[53,1142,1144],{"className":492,"code":1143,"language":494,"meta":58,"style":58},"insertDocument({\n  document_url: f.fileUrl,   \u002F\u002F ❌ bare URL, contains a literal +\n  file_name: f.name,\n  enable_status: withProcess ? 1 : 0,\n});\n",[17,1145,1146,1154,1162,1167,1185],{"__ignoreMap":58},[62,1147,1148,1151],{"class":64,"line":65},[62,1149,1150],{"class":381},"insertDocument",[62,1152,1153],{"class":514},"({\n",[62,1155,1156,1159],{"class":64,"line":71},[62,1157,1158],{"class":514},"  document_url: f.fileUrl,   ",[62,1160,1161],{"class":375},"\u002F\u002F ❌ bare URL, contains a literal +\n",[62,1163,1164],{"class":64,"line":77},[62,1165,1166],{"class":514},"  file_name: f.name,\n",[62,1168,1169,1172,1174,1177,1180,1182],{"class":64,"line":83},[62,1170,1171],{"class":514},"  enable_status: withProcess ",[62,1173,564],{"class":501},[62,1175,1176],{"class":385}," 1",[62,1178,1179],{"class":501}," :",[62,1181,774],{"class":385},[62,1183,1184],{"class":514},",\n",[62,1186,1187],{"class":64,"line":89},[62,1188,1189],{"class":514},"});\n",[13,1191,1192,1193,1195,1196,1198,1199,1201,1202,1205,1206,48],{},"The chain: the bare URL (with ",[17,1194,27],{},") is written to the DB → the backend reads it and sends an HTTP request → ",[17,1197,27],{}," is treated as a space → the content can't be fetched → ",[17,1200,23],{},". Meanwhile the frontend's preview and download have ",[17,1203,1204],{},"encodeOssUrl"," as a safety net, so \"reading\" looks fine, and ",[41,1207,1208],{},"that is exactly what masked the problem at the write entry point",[295,1210,1211],{},[13,1212,1213,1216],{},[41,1214,1215],{},"Key insight",": an encoding safety net on the frontend's \"read\" side cannot rescue dirty data that was \"written\" in. The true source is the value that goes into the database.",[13,1218,1219],{},"Fixing the write entry point:",[53,1221,1223],{"className":492,"code":1222,"language":494,"meta":58,"style":58},"insertDocument({\n  \u002F\u002F Encode before storing: the backend fetches by this URL, and a bare + \u002F space \u002F Chinese character makes the fetch fail\n  document_url: encodeOssUrl(f.fileUrl),   \u002F\u002F ✅\n  file_name: f.name,                        \u002F\u002F display name stays as is, not encoded\n  enable_status: withProcess ? 1 : 0,\n});\n",[17,1224,1225,1231,1236,1249,1257,1271],{"__ignoreMap":58},[62,1226,1227,1229],{"class":64,"line":65},[62,1228,1150],{"class":381},[62,1230,1153],{"class":514},[62,1232,1233],{"class":64,"line":71},[62,1234,1235],{"class":375},"  \u002F\u002F Encode before storing: the backend fetches by this URL, and a bare + \u002F space \u002F Chinese character makes the fetch fail\n",[62,1237,1238,1241,1243,1246],{"class":64,"line":77},[62,1239,1240],{"class":514},"  document_url: ",[62,1242,1204],{"class":381},[62,1244,1245],{"class":514},"(f.fileUrl),   ",[62,1247,1248],{"class":375},"\u002F\u002F ✅\n",[62,1250,1251,1254],{"class":64,"line":83},[62,1252,1253],{"class":514},"  file_name: f.name,                        ",[62,1255,1256],{"class":375},"\u002F\u002F display name stays as is, not encoded\n",[62,1258,1259,1261,1263,1265,1267,1269],{"class":64,"line":89},[62,1260,1171],{"class":514},[62,1262,564],{"class":501},[62,1264,1176],{"class":385},[62,1266,1179],{"class":501},[62,1268,774],{"class":385},[62,1270,1184],{"class":514},[62,1272,1273],{"class":64,"line":95},[62,1274,1189],{"class":514},[295,1276,1277],{},[13,1278,1279,1280,1283,1284,1287,1288,1290,1291,1294],{},"Do ",[41,1281,1282],{},"not"," encode ",[17,1285,1286],{},"file_name",". It is the display name meant for humans, and encoding it would show ",[17,1289,362],{}," in the list. ",[41,1292,1293],{},"Encode the URL field, keep the display field verbatim",", and keep the two responsibilities separate.",[13,1296,1297],{},"After this change, the whole chain is self-consistent:",[210,1299,1300,1313],{},[213,1301,1302],{},[216,1303,1304,1307,1310],{},[219,1305,1306],{},"Stage",[219,1308,1309],{},"URL form",[219,1311,1312],{},"Result",[231,1314,1315,1328,1344,1359],{},[216,1316,1317,1320,1325],{},[236,1318,1319],{},"Returned by the OSS upload",[236,1321,446,1322],{},[17,1323,1324],{},"…+…",[236,1326,1327],{},"—",[216,1329,1330,1333,1341],{},[236,1331,1332],{},"Registered in the DB",[236,1334,1335,1337,1338],{},[17,1336,1204],{}," → ",[17,1339,1340],{},"…%2B…",[236,1342,1343],{},"The DB stores the encoded form",[216,1345,1346,1348,1356],{},[236,1347,134],{},[236,1349,1350,1351,1353,1354],{},"Requests ",[17,1352,362],{}," → OSS decodes it back to ",[17,1355,27],{},[236,1357,1358],{},"✅ Hit, fetch succeeds",[216,1360,1361,1364,1373],{},[236,1362,1363],{},"List response → preview \u002F download",[236,1365,1366,1367,1369,1370,1372],{},"The DB's ",[17,1368,1340],{}," goes through ",[17,1371,1204],{}," again (idempotent)",[236,1374,1375],{},"✅ Hit",[33,1377,1379],{"id":1378},"_7-four-hidden-pits-the-best-part","7. Four hidden pits (the best part)",[193,1381,1383,1384,1386,1387],{"id":1382},"pit-1-idempotency-dont-double-encode-2b-into-252b","Pit 1: Idempotency — don't double-encode ",[17,1385,362],{}," into ",[17,1388,1389],{},"%252B",[13,1391,1392,1393,1395,1396,1398,1399,1402,1403,1405,1406,1409,1410,1412,1413,1422,1423,1426,1427,1430,1431,1433,1434,1436,1437,1440,1441,1444],{},"Once the write entry point encodes, the DB already stores ",[17,1394,1340],{},", and the frontend calls ",[17,1397,1204],{}," once more when \"reading\". If the implementation \"blindly encodes again\", the ",[17,1400,1401],{},"%"," in ",[17,1404,362],{}," gets encoded again into ",[17,1407,1408],{},"%25"," → it becomes the double-encoded ",[17,1411,1389],{},", and OSS can't find that either. The solution: ",[41,1414,1415,1416,1419,1420],{},"first restore with ",[17,1417,1418],{},"decodeURIComponent",", then ",[17,1421,546],{},", so the output is the same whether the input is a bare URL or an already-encoded one. That is ",[41,1424,1425],{},"idempotency",": ",[17,1428,1429],{},"f(f(x)) === f(x)",". It is the precondition for \"the read side and the write side share one function\" to hold. (",[17,1432,1418],{}," throws on a bare ",[17,1435,1401],{},", as in ",[17,1438,1439],{},"50%off.xlsx",", so a ",[17,1442,1443],{},"try\u002Fcatch"," fallback is needed.)",[193,1446,1448],{"id":1447},"pit-2-the-second-encoding-for-third-party-online-preview","Pit 2: The \"second encoding\" for third-party online preview",[13,1450,1451],{},"Browsers can't render Office documents directly, so Microsoft's online viewer is commonly used:",[53,1453,1455],{"className":492,"code":1454,"language":494,"meta":58,"style":58},"const officeUrl = computed(\n  () => `https:\u002F\u002Fview.officeapps.live.com\u002Fop\u002Fembed.aspx?src=${encodeURIComponent(encodedUrl.value)}`\n);\n",[17,1456,1457,1471,1498],{"__ignoreMap":58},[62,1458,1459,1461,1464,1466,1468],{"class":64,"line":65},[62,1460,502],{"class":501},[62,1462,1463],{"class":385}," officeUrl",[62,1465,508],{"class":501},[62,1467,511],{"class":381},[62,1469,1470],{"class":514},"(\n",[62,1472,1473,1476,1478,1481,1483,1485,1488,1490,1493,1495],{"class":64,"line":71},[62,1474,1475],{"class":514},"  () ",[62,1477,518],{"class":501},[62,1479,1480],{"class":392}," `https:\u002F\u002Fview.officeapps.live.com\u002Fop\u002Fembed.aspx?src=${",[62,1482,546],{"class":381},[62,1484,750],{"class":392},[62,1486,1487],{"class":514},"encodedUrl",[62,1489,48],{"class":392},[62,1491,1492],{"class":514},"value",[62,1494,699],{"class":392},[62,1496,1497],{"class":392},"}`\n",[62,1499,1500],{"class":64,"line":77},[62,1501,756],{"class":514},[13,1503,1504,1505,1508,1509,1511,1512,1337,1514,1516,1517,1520,1521,1523,1524,1526,1527,1530,1531,261,1534,261,1536,1538,1539,1541],{},"There are ",[41,1506,1507],{},"two layers of encoding"," here, and neither can be skipped: ① ",[17,1510,1487],{}," is already a path-safe URL (",[17,1513,27],{},[17,1515,362],{},"); ② it is stuffed into the Office URL as the ",[17,1518,1519],{},"src"," query parameter, so the whole thing gets ",[17,1522,546],{}," once more. The Office server decodes one layer off ",[17,1525,1519],{},", gets a clean URL back, and then fetches from OSS. ",[41,1528,1529],{},"Leave out the second layer",", and the ",[17,1532,1533],{},"&",[17,1535,489],{},[17,1537,658],{}," inside ",[17,1540,1519],{}," break the structure of Office's own URL, and the preview fails outright.",[295,1543,1544],{},[13,1545,1546,1547,1549],{},"Whenever you \"use one URL as a parameter of another URL\", the parameter layer always needs ",[17,1548,546],{},", and it must be applied on top of \"a safe URL that has already been processed\".",[193,1551,1553],{"id":1552},"pit-3-dont-damage-the-query-signed-urls","Pit 3: Don't damage the query (signed URLs)",[13,1555,1556,1557,1560,1561,1563,1564,1566,1567,1570,1571,1573,1574,160,1576,48],{},"Accessing a private bucket requires a signature, ",[17,1558,1559],{},"?Expires=...&Signature=...",", and the signature may itself contain ",[17,1562,27],{}," \u002F ",[17,1565,362],{},". But the query is computed by the backend according to an algorithm, and ",[41,1568,1569],{},"the frontend must never touch it"," (change one character and the signature is invalid). So ",[17,1572,1204],{}," splits at ",[17,1575,564],{},[41,1577,1578],{},"encodes only the path part, and appends the query back untouched",[193,1580,1582,1583,1586],{"id":1581},"pit-4-is-part-of-the-filename-not-a-fragment","Pit 4: ",[17,1584,1585],{},"#"," is part of the filename, not a fragment",[13,1588,1589,1591,1592,1595,1596,1599,1600,1603,1604,1607,1608,1610,1611,1614,1615,48],{},[17,1590,1585],{}," is perfectly legal in Windows \u002F macOS filenames (",[17,1593,1594],{},"会议纪要#3.docx",", \"meeting notes #3\"), but in a URL it marks the fragment anchor. In the first version I casually wrote ",[17,1597,1598],{},"split(\"#\")[0]"," to strip the fragment, which chopped off the whole ",[17,1601,1602],{},"#3.docx"," and produced ",[17,1605,1606],{},"…\u002F会议纪要",", creating yet another file that wouldn't open. OSS direct links have no fragment; a ",[17,1609,1585],{}," in a filename should be encoded as ",[17,1612,1613],{},"%23"," and treated as data, ",[41,1616,1617],{},"not cut off as a separator",[13,1619,1620],{},"The following cases can be used directly as regression tests (actual output):",[53,1622,1626],{"className":1623,"code":1624,"language":1625,"meta":58,"style":58},"language-txt shiki shiki-themes github-light github-dark github-dark","Product Doc_问题+答案.docx  →  Product%20Doc_%E9%97%AE%E9%A2%98%2B%E7%AD%94%E6%A1%88.docx\nreport&final.pdf           →  report%26final.pdf\n50%off.xlsx                →  50%25off.xlsx          ← a bare % is handled correctly too\n会议纪要#3.docx             →  %E4%BC%9A%E8%AE%AE%E7%BA%AA%E8%A6%81%233.docx   ← # → %23, not truncated\na b  c.txt                 →  a%20b%20%20c.txt       ← consecutive spaces\nx.docx?Expires=1&Sig=a+b   →  ...x.docx?Expires=1&Sig=a+b   ← query kept as is\n","txt",[17,1627,1628,1633,1638,1643,1648,1653],{"__ignoreMap":58},[62,1629,1630],{"class":64,"line":65},[62,1631,1632],{},"Product Doc_问题+答案.docx  →  Product%20Doc_%E9%97%AE%E9%A2%98%2B%E7%AD%94%E6%A1%88.docx\n",[62,1634,1635],{"class":64,"line":71},[62,1636,1637],{},"report&final.pdf           →  report%26final.pdf\n",[62,1639,1640],{"class":64,"line":77},[62,1641,1642],{},"50%off.xlsx                →  50%25off.xlsx          ← a bare % is handled correctly too\n",[62,1644,1645],{"class":64,"line":83},[62,1646,1647],{},"会议纪要#3.docx             →  %E4%BC%9A%E8%AE%AE%E7%BA%AA%E8%A6%81%233.docx   ← # → %23, not truncated\n",[62,1649,1650],{"class":64,"line":89},[62,1651,1652],{},"a b  c.txt                 →  a%20b%20%20c.txt       ← consecutive spaces\n",[62,1654,1655],{"class":64,"line":95},[62,1656,1657],{},"x.docx?Expires=1&Sig=a+b   →  ...x.docx?Expires=1&Sig=a+b   ← query kept as is\n",[33,1659,1661],{"id":1660},"_8-treating-the-symptom-vs-curing-the-disease","8. Treating the symptom vs. curing the disease",[13,1663,1664,1665,1668,1669,1672],{},"The \"encode uniformly at the access layer\" approach above ",[41,1666,1667],{},"treats the symptom",". It works, but it requires every single place that consumes the URL to remember to encode, and missing one spot means a failure (I missed the write entry point). ",[41,1670,1671],{},"The cure",": make the object key URL-safe from the very beginning, so special characters never get a chance to enter the URL at all.",[210,1674,1675,1687],{},[213,1676,1677],{},[216,1678,1679,1681,1684],{},[219,1680],{},[219,1682,1683],{},"Symptom: encode at the access layer",[219,1685,1686],{},"Cure: safe keys",[231,1688,1689,1706,1720,1731,1742],{},[216,1690,1691,1694,1699],{},[236,1692,1693],{},"Approach",[236,1695,1696,1697],{},"Every consumer uses ",[17,1698,1204],{},[236,1700,1701,1702,1705],{},"At upload, the key is ",[17,1703,1704],{},"{date}\u002F{uuid}.{ext}","; the original name is stored in a DB field",[216,1707,1708,1711,1714],{},[236,1709,1710],{},"Who changes",[236,1712,1713],{},"Frontend (or each consumer)",[236,1715,1716,1717,1719],{},"Backend upload logic + a ",[17,1718,1286],{}," field in the DB",[216,1721,1722,1725,1728],{},[236,1723,1724],{},"Pros",[236,1726,1727],{},"Small change, rescues existing data",[236,1729,1730],{},"URLs are always safe; all edge cases disappear at once",[216,1732,1733,1736,1739],{},[236,1734,1735],{},"Cons",[236,1737,1738],{},"Relies on no spot being missed; has edge cases",[236,1740,1741],{},"Needs backend changes; you lose \"reading the filename off the URL\"",[216,1743,1744,1747,1750],{},[236,1745,1746],{},"Original name on download",[236,1748,1749],{},"Use the encoded URL directly",[236,1751,1752,1753],{},"Filled back in via ",[17,1754,1755],{},"Content-Disposition",[13,1757,1758,1761,1762,1764,1765,1768],{},[41,1759,1760],{},"With the cure in place, how do you keep \"the download still has the original Chinese filename\"?"," Through the ",[17,1763,1755],{}," response header, using RFC 5987's ",[17,1766,1767],{},"filename*"," for non-ASCII names:",[53,1770,1772],{"className":1623,"code":1771,"language":1625,"meta":58,"style":58},"Content-Disposition: attachment;\n  filename=\"fallback.docx\";\n  filename*=UTF-8''Product%20Doc_%E9%97%AE%E9%A2%98%2B%E7%AD%94%E6%A1%88.docx\n",[17,1773,1774,1779,1784],{"__ignoreMap":58},[62,1775,1776],{"class":64,"line":65},[62,1777,1778],{},"Content-Disposition: attachment;\n",[62,1780,1781],{"class":64,"line":71},[62,1782,1783],{},"  filename=\"fallback.docx\";\n",[62,1785,1786],{"class":64,"line":77},[62,1787,1788],{},"  filename*=UTF-8''Product%20Doc_%E9%97%AE%E9%A2%98%2B%E7%AD%94%E6%A1%88.docx\n",[13,1790,1791,1794,1795,1797,1798,48],{},[17,1792,1793],{},"filename"," (the ASCII fallback) is for old browsers and ",[17,1796,1767],{}," (UTF-8 percent-encoded) is for modern ones; the downloaded file is still named ",[17,1799,19],{},[193,1801,1803],{"id":1802},"one-more-class-of-edge-cases-that-encoding-cant-save","One more class of edge cases that encoding can't save",[110,1805,1806,1818],{},[113,1807,1808,1814,1815,1817],{},[41,1809,1810,1811,1813],{},"A bare ",[17,1812,564],{}," in the filename",": syntactically it cannot be told apart from the query delimiter (fortunately Windows forbids ",[17,1816,564],{}," in filenames anyway, so it is rare in practice);",[113,1819,1820,1823,1824,1827],{},[41,1821,1822],{},"Unicode normalization differences",": filenames uploaded from macOS are in NFD (the decomposed form), while OSS \u002F Windows store them in NFC. ",[41,1825,1826],{},"They look identical to the eye but the bytes differ",", so the key simply doesn't match. Percent-encoding escapes byte by byte and can't help when the bytes themselves are inconsistent.",[13,1829,1830],{},"These two points are the hard reasons that push the \"safe key\" approach to the top.",[33,1832,1834],{"id":1833},"_9-what-about-existing-data","9. What about existing data?",[13,1836,1837,1838,1841,1842,1845,1846,1849,1850,1852,1853,1856,1857,1859],{},"After the fix shipped, ",[41,1839,1840],{},"new files"," were fine, but the ",[41,1843,1844],{},"historical records"," in the DB still held bare URLs: preview and download ",[41,1847,1848],{},"still work"," thanks to the ",[17,1851,1204],{}," safety net on the read path, but a backend re-fetch using the bare URL ",[41,1854,1855],{},"will still fail",". So existing data has to be handled separately: have the backend run a one-off script that batch-encodes ",[17,1858,106],{}," in the DB (the script must be idempotent too), or re-trigger registration \u002F processing for the affected files.",[33,1861,1863],{"id":1862},"_10-pitfall-checklist-take-it-as-is","10. Pitfall checklist (take it as is)",[1865,1866,1869,1882,1894,1904,1913,1919,1931,1940,1949,1958],"ul",{"className":1867},[1868],"contains-task-list",[113,1870,1873,1877,1878,638,1880],{"className":1871},[1872],"task-list-item",[1874,1875],"input",{"disabled":412,"type":1876},"checkbox"," Encode filenames \u002F path segments with ",[17,1879,546],{},[17,1881,481],{},[113,1883,1885,1887,1888,1890,1891,1893],{"className":1884},[1872],[1874,1886],{"disabled":412,"type":1876}," Encode segment by segment (split on ",[17,1889,658],{},"); don't encode the path separator ",[17,1892,658],{}," itself",[113,1895,1897,1899,1900,1903],{"className":1896},[1872],[1874,1898],{"disabled":412,"type":1876}," Share one ",[41,1901,1902],{},"idempotent"," encoding function between the read side and the write side (decode-then-encode)",[113,1905,1907,1909,1910,1912],{"className":1906},[1872],[1874,1908],{"disabled":412,"type":1876}," Encode the URL field; keep the display field (",[17,1911,1286],{},") verbatim",[113,1914,1916,1918],{"className":1915},[1872],[1874,1917],{"disabled":412,"type":1876}," Encode only the path, leave the query alone (a signed URL dies with a single change)",[113,1920,1922,1924,1925,1927,1928,1930],{"className":1921},[1872],[1874,1923],{"disabled":412,"type":1876}," Encode ",[17,1926,1585],{}," as ",[17,1929,1613],{},"; don't cut it off as a fragment",[113,1932,1934,1936,1937,1939],{"className":1933},[1872],[1874,1935],{"disabled":412,"type":1876}," For \"a URL as a parameter\", wrap one more layer of ",[17,1938,546],{}," (Office \u002F any online preview)",[113,1941,1943,1945,1946,1948],{"className":1942},[1872],[1874,1944],{"disabled":412,"type":1876}," When debugging, check the status code with ",[17,1947,348],{}," first, decoupling storage reachability from upper-layer rendering",[113,1950,1952,1954,1955,1957],{"className":1951},[1872],[1874,1953],{"disabled":412,"type":1876}," Cure it properly if you can: safe uuid keys + original name in the DB + ",[17,1956,1755],{}," on download",[113,1959,1961,1963],{"className":1960},[1872],[1874,1962],{"disabled":412,"type":1876}," Don't forget to migrate existing data",[33,1965,1967],{"id":1966},"_11-summary-in-one-sentence","11. Summary in one sentence",[295,1969,1970],{},[13,1971,1972,1973,1975,1976,1426,1979,1981,1982,1984],{},"The disaster caused by a single ",[17,1974,27],{}," is, at its core, a ",[41,1977,1978],{},"\"read\u002Fwrite consistency\" problem in URL encoding",[17,1980,27],{}," has two identities, \"space\" and \"literal plus\", and ",[17,1983,481],{}," happens not to encode it. The real fix is not on the \"read\" side (preview \u002F download) but on the \"write\" side (the value that goes into the database). The most robust approach is to make object keys URL-safe from birth.",[1986,1987],"hr",{},[33,1989,1991],{"id":1990},"references","References",[1865,1993,1994,2007,2014,2021,2028],{},[113,1995,1996,2003,2004,2006],{},[1997,1998,2002],"a",{"href":1999,"rel":2000},"https:\u002F\u002Fdatatracker.ietf.org\u002Fdoc\u002Fhtml\u002Frfc3986",[2001],"nofollow","RFC 3986 — URI Generic Syntax"," (§2.2 sub-delims, where ",[17,2005,27],{}," belongs)",[113,2008,2009],{},[1997,2010,2013],{"href":2011,"rel":2012},"https:\u002F\u002Fdeveloper.mozilla.org\u002Fzh-CN\u002Fdocs\u002FWeb\u002FJavaScript\u002FReference\u002FGlobal_Objects\u002FencodeURIComponent",[2001],"MDN — encodeURIComponent()",[113,2015,2016],{},[1997,2017,2020],{"href":2018,"rel":2019},"https:\u002F\u002Fhelp.aliyun.com\u002Fzh\u002Foss\u002Fwhat-can-i-do-if-i-cannot-access-an-object-by-using-the-object-url",[2001],"Alibaba Cloud OSS — Troubleshooting an object URL that cannot be accessed (in Chinese)",[113,2022,2023],{},[1997,2024,2027],{"href":2025,"rel":2026},"https:\u002F\u002Fhelp.aliyun.com\u002Fzh\u002Foss\u002Fuser-guide\u002Fset-the-file-name-for-downloading-an-oss-file",[2001],"Alibaba Cloud OSS — Setting a custom filename for downloads via Content-Disposition (in Chinese)",[113,2029,2030],{},[1997,2031,2034],{"href":2032,"rel":2033},"https:\u002F\u002Fwww.codestudy.net\u002Fblog\u002Furl-encoding-the-space-character-or-20\u002F",[2001],"URL Encoding Spaces: + vs %20",[2036,2037,2038],"style",{},"html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .sCsY4, html code.shiki .sCsY4{--shiki-light:#6A737D;--shiki-default:#6A737D;--shiki-dark:#6A737D}html pre.shiki code .shcOC, html code.shiki .shcOC{--shiki-light:#6F42C1;--shiki-default:#B392F0;--shiki-dark:#B392F0}html pre.shiki code .suiK_, html code.shiki .suiK_{--shiki-light:#005CC5;--shiki-default:#79B8FF;--shiki-dark:#79B8FF}html pre.shiki code .sfrk1, html code.shiki .sfrk1{--shiki-light:#032F62;--shiki-default:#9ECBFF;--shiki-dark:#9ECBFF}html pre.shiki code .so5gQ, html code.shiki .so5gQ{--shiki-light:#D73A49;--shiki-default:#F97583;--shiki-dark:#F97583}html pre.shiki code .slsVL, html code.shiki .slsVL{--shiki-light:#24292E;--shiki-default:#E1E4E8;--shiki-dark:#E1E4E8}html pre.shiki code .sQHwn, html code.shiki .sQHwn{--shiki-light:#E36209;--shiki-default:#FFAB70;--shiki-dark:#FFAB70}",{"title":58,"searchDepth":71,"depth":71,"links":2040},[2041,2042,2043,2050,2052,2053,2054,2062,2065,2066,2067,2068],{"id":35,"depth":71,"text":36},{"id":141,"depth":71,"text":142},{"id":188,"depth":71,"text":2044,"children":2045},"3. Digging for the root cause: the \"dual identity\" of +",[2046,2048,2049],{"id":195,"depth":77,"text":2047},"3.1 What does + actually mean in a URL?",{"id":312,"depth":77,"text":313},{"id":341,"depth":77,"text":342},{"id":477,"depth":71,"text":2051},"4. Why does it still slip through when \"it's clearly encoded\"? The encodeURI trap",{"id":644,"depth":71,"text":645},{"id":1121,"depth":71,"text":1122},{"id":1378,"depth":71,"text":1379,"children":2055},[2056,2058,2059,2060],{"id":1382,"depth":77,"text":2057},"Pit 1: Idempotency — don't double-encode %2B into %252B",{"id":1447,"depth":77,"text":1448},{"id":1552,"depth":77,"text":1553},{"id":1581,"depth":77,"text":2061},"Pit 4: # is part of the filename, not a fragment",{"id":1660,"depth":71,"text":1661,"children":2063},[2064],{"id":1802,"depth":77,"text":1803},{"id":1833,"depth":71,"text":1834},{"id":1862,"depth":71,"text":1863},{"id":1966,"depth":71,"text":1967},{"id":1990,"depth":71,"text":1991},"2026-06-27","One innocent plus sign in a filename made a successfully uploaded file impossible to preview and turned the backend parser into a 500. A full post-mortem, from symptom to root cause and from patch to cure, with the URL-encoding traps I hit along the way.","md",null,"\u002Farticles\u002Foss-filename-url-encoding.svg",{},"\u002Farticles\u002Foss-filename-url-encoding",4.5,"13",{"title":5,"description":2070},{"loc":2075},"articles\u002Foss-filename-url-encoding",[2082,2083],"Frontend","Debugging","KTJ7fqfVCj_KTGFzqyQ0GmrekYKQwGQD7Jk0eO1iEAE",1795761651866]