FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
codeql/javascript/ql/src/DOM/PseudoEval.qhelp at codeql-cli/v2.19.2 · github/codeql · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
github
/
codeql
Public
Notifications
You must be signed in to change notification settings
Fork
2.1k
Star
10k
Code
Issues
997
Pull requests
467
Discussions
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Discussions
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
codeql
/
javascript
/
ql
/
src
/
DOM
/
PseudoEval.qhelp
Copy path
More file actions
More file actions
Latest commit
History
History
History
48 lines (35 loc) · 1.08 KB
Breadcrumbs
codeql
/
javascript
/
ql
/
src
/
DOM
/
PseudoEval.qhelp
Copy path
File metadata and controls
48 lines (35 loc) · 1.08 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<!
DOCTYPE
qhelp
PUBLIC
"-//Semmle//qhelp//EN"
"qhelp.dtd">
<
qhelp
>
<
overview
>
<
p
>
Several DOM functions allow evaluating strings as code without using <
code
>eval</
code
> explicitly.
They should be avoided for the same reason as <
code
>eval</
code
> itself.
</
p
>
</
overview
>
<
recommendation
>
<
p
>
When calling <
code
>setTimeout</
code
> or <
code
>setInterval</
code
>, do not pass it a string to evaluate
but a function.
</
p
>
<
p
>
Instead of using <
code
>document.write</
code
> to insert raw HTML into the DOM, use a framework such as
<
a
href
=
"
http://jquery.com
"
>jQuery</
a
>.
</
p
>
</
recommendation
>
<
example
>
<
p
>
In the following example, <
code
>setTimeout</
code
> is used to register a callback. The code to execute
once the timeout expires is given as a string; this is bad practice.
</
p
>
<
sample
src
=
"
examples/PseudoEval.js
"
/>
<
p
>
Instead, directly pass the function to be invoked to <
code
>setTimeout</
code
> like this:
</
p
>
<
sample
src
=
"
examples/PseudoEvalGood.js
"
/>
</
example
>
<
references
>
<
li
>D. Crockford, <
i
>JavaScript: The Good Parts</
i
>, Appendix B.3. O'Reilly, 2008.</
li
>
</
references
>
</
qhelp
>
Back
|
FazBrowse Home
|
New Git URL