-
-
Notifications
You must be signed in to change notification settings - Fork 418
patch 1.4.19 #1610
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
patch 1.4.19 #1610
Changes from all commits
3143445
c95af80
97e8dee
80bb84d
e0b0534
2d30e61
620d96b
daaea8b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,22 +1,9 @@ | ||
| import { Elysia, t } from '../src' | ||
| import * as z from 'zod' | ||
| import { post, req } from '../test/utils' | ||
| import { Elysia } from '../src' | ||
|
|
||
| const app = new Elysia({ | ||
| cookie: { | ||
| domain: "\\` + console.log(c.q='pwn2') }) //" | ||
| } | ||
| }) | ||
| .get('/', ({ cookie: { session } }) => 'awd') | ||
|
|
||
| console.log(app.routes[0].compile().toString()) | ||
|
|
||
| const root = await app.handle( | ||
| new Request('http://localhost/', { | ||
| headers: { | ||
| Cookie: 'session=1234' | ||
| } | ||
| const app = new Elysia() | ||
| .group('', (app) => { | ||
| return app.get('/ok', () => 'Hello World') | ||
| }) | ||
| ) | ||
| .listen(3000) | ||
|
|
||
| console.log(await root.text()) | ||
| type Routes = keyof typeof app['~Routes'] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -551,8 +551,36 @@ export const isContextPassToFunction = ( | |
| ) => { | ||
| // ! Function is passed to another function, assume as all is accessed | ||
| try { | ||
| const captureFunction = new RegExp(`\\w\\((.*?)?${context}`, 'gs') | ||
| captureFunction.test(body) | ||
| const captureFunction = new RegExp( | ||
| `\\w\\((?:.*?)?${context}(?:.*?)?\\)`, | ||
| 'gs' | ||
| ) | ||
| const exactParameter = new RegExp(`${context}(,|\\))`, 'gs') | ||
|
|
||
| const length = body.length | ||
| let fn | ||
|
|
||
| fn = captureFunction.exec(body) + '' | ||
| while ( | ||
| captureFunction.lastIndex !== 0 && | ||
| captureFunction.lastIndex < length + (fn ? fn.length : 0) | ||
| ) { | ||
| if (fn && exactParameter.test(fn)) { | ||
| inference.query = true | ||
| inference.headers = true | ||
| inference.body = true | ||
| inference.cookie = true | ||
| inference.set = true | ||
| inference.server = true | ||
| inference.url = true | ||
| inference.route = true | ||
| inference.path = true | ||
|
|
||
| return true | ||
| } | ||
|
|
||
| fn = captureFunction.exec(body) + '' | ||
| } | ||
|
|
||
| /* | ||
| Since JavaScript engine already format the code (removing whitespace, newline, etc.), | ||
|
|
@@ -700,7 +728,11 @@ export const sucrose = ( | |
| code.charCodeAt(0) === 123 && | ||
| code.charCodeAt(body.length - 1) === 125 | ||
| ) | ||
| code = code.slice(1, -1) | ||
| code = code.slice(1, -1).trim() | ||
|
|
||
| console.log( | ||
| isContextPassToFunction(mainParameter, code, fnInference) | ||
| ) | ||
|
|
||
| if (!isContextPassToFunction(mainParameter, code, fnInference)) | ||
|
Comment on lines
+733
to
737
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove debug Inside console.log(
isContextPassToFunction(mainParameter, code, fnInference)
)This will execute for every analyzed handler in production, producing noisy logs and adding overhead in hot paths where routing/inference is performed. Recommend either removing this log entirely or guarding it behind an explicit debug flag / environment check so it doesn’t run in normal usage. 🤖 Prompt for AI Agents |
||
| inferBodyReference(code, aliases, fnInference) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix duplicate link reference on line 7.
Both references point to PR
#1591. The second reference should point to#1590instead.📝 Committable suggestion
🤖 Prompt for AI Agents