Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
6f028440
Commit
6f028440
authored
Jan 09, 2026
by
Jiachi Liu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
only check on certain chars
parent
61b210f8
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
2 deletions
+7
-2
mojibake.ts
packages/next/src/server/lib/mojibake.ts
+3
-2
utils.ts
packages/next/src/server/web/utils.ts
+4
-0
No files found.
packages/next/src/server/lib/mojibake.ts
View file @
6f028440
...
@@ -35,8 +35,9 @@ export function encodeMojibake(input: string): string {
...
@@ -35,8 +35,9 @@ export function encodeMojibake(input: string): string {
* @returns The decoded UTF-8 string, or the original if not Mojibake
* @returns The decoded UTF-8 string, or the original if not Mojibake
*/
*/
export
function
decodeMojibake
(
input
:
string
):
string
{
export
function
decodeMojibake
(
input
:
string
):
string
{
// Check if value contains non-ASCII characters that could be Mojibake
// Check if value contains Latin-1 extended characters (128-255) that could be Mojibake.
// We use [\x80-\xFF] instead of [^\u0000-\u007F] because Mojibake only produces
// characters in the Latin-1 range (0-255), not full Unicode.
if
(
!
/
[\x
80-
\x
FF
]
/
.
test
(
input
))
{
if
(
!
/
[\x
80-
\x
FF
]
/
.
test
(
input
))
{
return
input
return
input
}
}
...
...
packages/next/src/server/web/utils.ts
View file @
6f028440
...
@@ -177,6 +177,10 @@ export function normalizeNextQueryParam(key: string): null | string {
...
@@ -177,6 +177,10 @@ export function normalizeNextQueryParam(key: string): null | string {
* Checks if a string contains any non-ASCII characters (code points > 127).
* Checks if a string contains any non-ASCII characters (code points > 127).
* ASCII characters are in the range U+0000 to U+007F.
* ASCII characters are in the range U+0000 to U+007F.
*
*
* We use [^\u0000-\u007F] (matches anything outside ASCII) instead of [\x80-\xFF]
* (matches only Latin-1 extended 128-255) because HTTP headers may contain
* any Unicode character that needs encoding, not just Latin-1.
*
* @param value - The string to check
* @param value - The string to check
* @returns true if the string contains non-ASCII characters
* @returns true if the string contains non-ASCII characters
*/
*/
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment