fix(protocol): harden friend dress queries

Require the dress page to identify the requested account and every returned item before exposing the result. Reject malformed nested media metadata instead of silently degrading it.

Bound the HTML request to a 10-second redirect-chain deadline and a 2 MiB response body. Secure redirects by closing previous connections, stripping cross-origin credentials, rejecting cross-origin write forwarding, and surfacing malformed locations.

Replace the captured page with a minimal sanitized fixture and add protocol plus OneBot Action regression coverage for resource limits, redirect safety, response ownership, and structured failures.
This commit is contained in:
DrSmoothl committed 2026-07-25 20:22:49 +08:00
1 parent 3517257aa6
commit 13a32a2865
6 files changed
+681 -377

No files matched your search

@@ -0,0 +1,43 @@
import { describe, expect, it, vi } from 'vitest';
import { FriendDressError } from '@snowluma/protocol/web/friend-dress';
import { ApiHandler, type ApiActionContext } from '../src/api-handler';
function makeHandler(getFriendDress: ReturnType<typeof vi.fn>): ApiHandler {
const bridge = { apis: { web: { getFriendDress } } };
return new ApiHandler({ bridge } as unknown as ApiActionContext);
}
describe('_get_friend_dress action', () => {
it('validates the target and returns the queried dress data', async () => {
const dress = {
target_uin: '10000',
is_svip: false,
avatar_url: '',
items: [],
};
const getFriendDress = vi.fn().mockResolvedValue(dress);
const response = await makeHandler(getFriendDress).handle(
'_get_friend_dress',
{ user_id: '10000' },
);
expect(response).toMatchObject({ status: 'ok', retcode: 0, data: dress });
expect(getFriendDress).toHaveBeenCalledWith(10000);
});
it('preserves the structured failure kind in the Action response', async () => {
const getFriendDress = vi.fn().mockRejectedValue(
new FriendDressError('uin_mismatch', 'returned account does not match'),
);
const response = await makeHandler(getFriendDress).handle(
'_get_friend_dress',
{ user_id: 10000 },
);
expect(response).toMatchObject({ status: 'failed', retcode: 100 });
expect(response.wording).toContain('(uin_mismatch)');
expect(response.wording).toContain('returned account does not match');
});
});
+63 -19
View File
@@ -79,8 +79,13 @@ const TRACE_DETAIL =
const DRESS_UA =
'Mozilla/5.0 (Linux; Android 13; 2109119BC Build/TKQ1.221114.001; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/121.0.6167.71 MQQBrowser/6.2 TBS/047925 Mobile Safari/537.36 V1_AND_SQ_9.2.66_13188_YYB_D QQ/9.2.66.33870 NetType/WIFI WebP/0.3.0 AppId/537339358';
const DRESS_RESPONSE_LIMITS = {
timeoutMs: 10_000,
maxResponseBytes: 2 * 1024 * 1024,
} as const;
interface RawDressItem {
appId?: number;
appId: number;
itemId?: number;
name?: string;
image?: string;
@@ -130,13 +135,15 @@ function parseAsyncData(html: string): unknown {
}
/** 运行时结构校验:不符合预期的一律抛 structure,绝不带着畸形数据继续。 */
function validateAsyncData(data: unknown): RawAsyncData & { rawUsingList: RawDressItem[] } {
function validateAsyncData(
data: unknown,
): RawAsyncData & { targetUin: string; rawUsingList: RawDressItem[] } {
if (data === null || typeof data !== 'object' || Array.isArray(data)) {
throw new FriendDressError('structure', '__INITIAL_ASYNCDATA__ 顶层不是对象');
}
const d = data as Record<string, unknown>;
if (d['targetUin'] !== undefined && typeof d['targetUin'] !== 'string') {
throw new FriendDressError('structure', 'targetUin 不是字符串');
if (typeof d['targetUin'] !== 'string' || d['targetUin'].length === 0) {
throw new FriendDressError('structure', 'targetUin 缺失或不是非空字符串');
}
if (d['isSvip'] !== undefined && typeof d['isSvip'] !== 'boolean') {
throw new FriendDressError('structure', 'isSvip 不是布尔值');
@@ -152,8 +159,8 @@ function validateAsyncData(data: unknown): RawAsyncData & { rawUsingList: RawDre
throw new FriendDressError('structure', `rawUsingList[${i}] 不是对象`);
}
const r = item as Record<string, unknown>;
if (r['appId'] !== undefined && typeof r['appId'] !== 'number') {
throw new FriendDressError('structure', `rawUsingList[${i}].appId 不是数字`);
if (typeof r['appId'] !== 'number') {
throw new FriendDressError('structure', `rawUsingList[${i}].appId 缺失或不是数字`);
}
if (r['itemId'] !== undefined && typeof r['itemId'] !== 'number') {
throw new FriendDressError('structure', `rawUsingList[${i}].itemId 不是数字`);
@@ -164,8 +171,28 @@ function validateAsyncData(data: unknown): RawAsyncData & { rawUsingList: RawDre
if (r['image'] !== undefined && typeof r['image'] !== 'string') {
throw new FriendDressError('structure', `rawUsingList[${i}].image 不是字符串`);
}
if (r['extraappinfo'] !== undefined) {
if (r['extraappinfo'] === null
|| typeof r['extraappinfo'] !== 'object'
|| Array.isArray(r['extraappinfo'])) {
throw new FriendDressError('structure', `rawUsingList[${i}].extraappinfo 不是对象`);
}
const extraInfo = (r['extraappinfo'] as Record<string, unknown>)['extraInfo'];
if (extraInfo !== undefined) {
if (extraInfo === null || typeof extraInfo !== 'object' || Array.isArray(extraInfo)) {
throw new FriendDressError('structure', `rawUsingList[${i}].extraappinfo.extraInfo 不是对象`);
}
const immersiveMaterial = (extraInfo as Record<string, unknown>)['immersiveMaterial'];
if (immersiveMaterial !== undefined && typeof immersiveMaterial !== 'string') {
throw new FriendDressError(
'structure',
`rawUsingList[${i}].extraappinfo.extraInfo.immersiveMaterial 不是字符串`,
);
}
}
}
});
return data as RawAsyncData & { rawUsingList: RawDressItem[] };
return data as RawAsyncData & { targetUin: string; rawUsingList: RawDressItem[] };
}
/**
@@ -177,13 +204,31 @@ function validateAsyncData(data: unknown): RawAsyncData & { rawUsingList: RawDre
function resolveVideoUrl(r: RawDressItem): string {
if (r.appId === 15) {
const raw = r.extraappinfo?.extraInfo?.immersiveMaterial;
if (typeof raw !== 'string' || !raw) return '';
if (raw === undefined) return '';
let material: unknown;
try {
const videoUrl = (JSON.parse(raw) as { videoUrl?: unknown }).videoUrl;
return typeof videoUrl === 'string' ? videoUrl : '';
} catch {
return '';
material = JSON.parse(raw) as unknown;
} catch (error) {
throw new FriendDressError(
'structure',
`装扮 appId=${r.appId} itemId=${r.itemId ?? 0} 的 immersiveMaterial 不是合法 JSON`,
{ cause: error },
);
}
if (material === null || typeof material !== 'object' || Array.isArray(material)) {
throw new FriendDressError(
'structure',
`装扮 appId=${r.appId} itemId=${r.itemId ?? 0} 的 immersiveMaterial 不是对象`,
);
}
const videoUrl = (material as Record<string, unknown>)['videoUrl'];
if (typeof videoUrl !== 'string' || videoUrl.length === 0) {
throw new FriendDressError(
'structure',
`装扮 appId=${r.appId} itemId=${r.itemId ?? 0} 的 immersiveMaterial.videoUrl 缺失或不是非空字符串`,
);
}
return videoUrl;
}
if (r.appId === 17 && r.image && /\/(?:web_)?image\.jpg$/.test(r.image)) {
return r.image.replace(/\/(?:web_)?image\.jpg$/, '/media.mp4');
@@ -192,10 +237,9 @@ function resolveVideoUrl(r: RawDressItem): string {
}
function toItem(r: RawDressItem): WebFriendDressItem {
const appId = r.appId ?? 0;
return {
app_id: appId,
kind: APP_KIND[appId] ?? `appId=${appId}`,
app_id: r.appId,
kind: APP_KIND[r.appId] ?? `appId=${r.appId}`,
item_id: r.itemId ?? 0,
name: r.name ?? '',
preview_url: r.image ?? '',
@@ -220,22 +264,22 @@ export async function getFriendDressWebAPI(
'User-Agent': DRESS_UA,
Accept: 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
'Accept-Language': 'zh-CN,zh;q=0.9',
});
}, DRESS_RESPONSE_LIMITS);
} catch (e) {
throw new FriendDressError('network', `装扮页请求失败: ${e instanceof Error ? e.message : String(e)}`, { cause: e });
}
const data = validateAsyncData(parseAsyncData(html));
if (data.targetUin !== undefined && data.targetUin !== targetUin) {
if (data.targetUin !== targetUin) {
throw new FriendDressError('uin_mismatch', `装扮页返回账号 ${data.targetUin} 与请求账号 ${targetUin} 不一致`);
}
return {
target_uin: data.targetUin ?? targetUin,
target_uin: data.targetUin,
is_svip: data.isSvip ?? false,
avatar_url: data.avatarImage ?? '',
items: data.rawUsingList
.filter((r) => !UNRESOLVABLE_APPS.has(r.appId ?? 0))
.filter((r) => !UNRESOLVABLE_APPS.has(r.appId))
.map(toItem),
};
}
+209 -26
View File
@@ -3,6 +3,52 @@ import https from 'node:https';
type RequestBody = string | Buffer | Uint8Array | Record<string, unknown> | undefined;
export interface HttpResponseLimits {
/** Wall-clock deadline shared by the complete redirect chain. */
timeoutMs?: number;
/** Maximum response body size measured in bytes before decoding. */
maxResponseBytes?: number;
}
function validateLimit(name: keyof HttpResponseLimits, value: number | undefined): void {
const exceedsTimerRange = name === 'timeoutMs' && value !== undefined && value > 2_147_483_647;
if (value !== undefined && (!Number.isSafeInteger(value) || value <= 0 || exceedsTimerRange)) {
throw new Error(`${name} must be a positive safe integer`);
}
}
interface HttpRequestContext {
url: string;
method: string;
data?: RequestBody;
headers: Record<string, string>;
isJsonRet: boolean;
isArgJson: boolean;
maxRedirects: number;
responseLimits: HttpResponseLimits;
deadlineAt?: number;
}
const SENSITIVE_REDIRECT_HEADERS = new Set([
'authorization',
'cookie',
'cookie2',
'host',
'proxy-authorization',
]);
function headersForRedirect(
headers: Record<string, string>,
source: URL,
target: URL,
): Record<string, string> {
if (source.origin === target.origin) return headers;
return Object.fromEntries(
Object.entries(headers)
.filter(([name]) => !SENSITIVE_REDIRECT_HEADERS.has(name.toLowerCase())),
);
}
export class RequestUtil {
// Collect Set-Cookie across the ptlogin2 jump's redirect chain. NEVER hangs:
// a per-request timeout + a redirect-depth cap guarantee termination, and any
@@ -57,61 +103,198 @@ export class RequestUtil {
static async HttpGetJson<T>(url: string, method: string = 'GET', data?: RequestBody, headers: {
[key: string]: string;
} = {}, isJsonRet: boolean = true, isArgJson: boolean = true, maxRedirects: number = 5): Promise<T> {
const option = new URL(url);
const protocol = url.startsWith('https://') ? https : http;
} = {}, isJsonRet: boolean = true, isArgJson: boolean = true, maxRedirects: number = 5,
responseLimits: HttpResponseLimits = {}): Promise<T> {
validateLimit('timeoutMs', responseLimits.timeoutMs);
validateLimit('maxResponseBytes', responseLimits.maxResponseBytes);
return this.request<T>({
url,
method,
data,
headers,
isJsonRet,
isArgJson,
maxRedirects,
responseLimits,
deadlineAt: responseLimits.timeoutMs === undefined
? undefined
: Date.now() + responseLimits.timeoutMs,
});
}
private static async request<T>(context: HttpRequestContext): Promise<T> {
const option = new URL(context.url);
const protocol = option.protocol === 'https:'
? https
: option.protocol === 'http:'
? http
: undefined;
if (!protocol) {
throw new Error(`unsupported request protocol: ${option.protocol}`);
}
const remainingTimeoutMs = context.deadlineAt === undefined
? undefined
: context.deadlineAt - Date.now();
if (remainingTimeoutMs !== undefined && remainingTimeoutMs <= 0) {
throw new Error(`request timed out after ${context.responseLimits.timeoutMs} ms`);
}
const options = {
hostname: option.hostname,
port: option.port,
path: option.pathname + option.search,
method,
headers,
method: context.method,
headers: context.headers,
};
return new Promise((resolve, reject) => {
let settled = false;
let timeout: NodeJS.Timeout | undefined;
const clearDeadline = () => {
if (timeout !== undefined) clearTimeout(timeout);
};
const resolveOnce = (value: T) => {
if (settled) return;
settled = true;
clearDeadline();
resolve(value);
};
const rejectOnce = (error: Error) => {
if (settled) return;
settled = true;
clearDeadline();
reject(error);
};
const handOff = (next: Promise<T>) => {
if (settled) return;
settled = true;
clearDeadline();
next.then(resolve).catch(reject);
};
const req = protocol.request(options, (res: http.IncomingMessage) => {
const closeCurrent = () => {
res.destroy();
req.destroy();
};
res.once('error', (error: Error) => rejectOnce(error));
if ((res.statusCode === 301 || res.statusCode === 302 || res.statusCode === 307 || res.statusCode === 308) && res.headers.location) {
if (maxRedirects <= 0) {
reject(new Error('Too many redirects'));
if (context.maxRedirects <= 0) {
rejectOnce(new Error('Too many redirects'));
closeCurrent();
return;
}
const redirectUrl = new URL(res.headers.location, url).href;
this.HttpGetJson<T>(redirectUrl, method, data, headers, isJsonRet, isArgJson, maxRedirects - 1)
.then(resolve)
.catch(reject);
let redirectUrl: URL;
try {
redirectUrl = new URL(res.headers.location, option);
} catch (error) {
rejectOnce(new Error('invalid redirect location', { cause: error }));
closeCurrent();
return;
}
if (redirectUrl.protocol !== 'http:' && redirectUrl.protocol !== 'https:') {
rejectOnce(new Error(`unsupported redirect protocol: ${redirectUrl.protocol}`));
closeCurrent();
return;
}
if (option.origin !== redirectUrl.origin
&& context.method.toUpperCase() !== 'GET'
&& context.method.toUpperCase() !== 'HEAD') {
rejectOnce(new Error(
`cross-origin redirect cannot forward method ${context.method.toUpperCase()}`,
));
closeCurrent();
return;
}
handOff(this.request<T>({
...context,
url: redirectUrl.href,
headers: headersForRedirect(context.headers, option, redirectUrl),
maxRedirects: context.maxRedirects - 1,
}));
closeCurrent();
return;
}
let responseBody = '';
res.on('data', (chunk: string | Buffer) => { responseBody += chunk.toString(); });
if (!res.statusCode || res.statusCode < 200 || res.statusCode >= 300) {
rejectOnce(new Error(`Unexpected status code: ${res.statusCode}`));
closeCurrent();
return;
}
const chunks: Buffer[] = [];
let responseBytes = 0;
res.on('data', (chunk: string | Buffer) => {
if (settled) return;
const bytes = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk);
responseBytes += bytes.length;
if (context.responseLimits.maxResponseBytes !== undefined
&& responseBytes > context.responseLimits.maxResponseBytes) {
const error = new Error(
`response body exceeds ${context.responseLimits.maxResponseBytes} bytes`,
);
rejectOnce(error);
closeCurrent();
return;
}
chunks.push(bytes);
});
res.on('end', () => {
if (settled) return;
const responseBody = Buffer.concat(chunks, responseBytes).toString();
try {
if (res.statusCode && res.statusCode >= 200 && res.statusCode < 300) {
if (isJsonRet) {
resolve(JSON.parse(responseBody) as T);
} else {
resolve(responseBody as T);
}
if (context.isJsonRet) {
resolveOnce(JSON.parse(responseBody) as T);
} else {
reject(new Error(`Unexpected status code: ${res.statusCode}`));
resolveOnce(responseBody as T);
}
} catch (parseError: unknown) {
reject(new Error(parseError instanceof Error ? parseError.message : String(parseError)));
rejectOnce(new Error(parseError instanceof Error ? parseError.message : String(parseError)));
}
});
});
req.on('error', (error: Error) => reject(error));
if (method === 'POST' || method === 'PUT' || method === 'PATCH') {
req.write(isArgJson ? JSON.stringify(data) : data);
if (remainingTimeoutMs !== undefined) {
timeout = setTimeout(() => {
const error = new Error(
`request timed out after ${context.responseLimits.timeoutMs} ms`,
);
rejectOnce(error);
req.destroy();
}, remainingTimeoutMs);
}
req.on('error', (error: Error) => rejectOnce(error));
if (context.method === 'POST' || context.method === 'PUT' || context.method === 'PATCH') {
req.write(context.isArgJson ? JSON.stringify(context.data) : context.data);
}
req.end();
});
}
static async HttpGetText(url: string, method: string = 'GET', data?: RequestBody, headers: { [key: string]: string; } = {}) {
return this.HttpGetJson<string>(url, method, data, headers, false, false);
static async HttpGetText(
url: string,
method: string = 'GET',
data?: RequestBody,
headers: { [key: string]: string; } = {},
responseLimits: HttpResponseLimits = {},
) {
return this.HttpGetJson<string>(
url,
method,
data,
headers,
false,
false,
5,
responseLimits,
);
}
}
@@ -1,320 +1,66 @@
<!DOCTYPE html>
<!doctype html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8" />
<meta name="HandheldFriendly" content="True" />
<meta name="format-detection" content="telephone=no" />
<meta name="viewport"
content="width=device-width,initial-scale=1,minimum-scale=1, maximum-scale=1, user-scalable=no, viewport-fit=cover" />
<style type="text/css">
.dark {
background-color: #000;
min-height: 100vh;
}
body {
margin: 0px;
}
</style>
<body>
<!--
Sanitized from a real QQ friend-dress SSR response. Only fields consumed
by SnowLuma remain; account identifiers, timestamps, tracking markup,
recommendation data, and embedded assets have been removed.
-->
<script>
window._HTML_BEGIN_TIMESTAMP_ = Date.now();
window.inReloadingScriptNumber = 0;
window.hasReloadedScriptMap = {};
window.addEventListener(
"error",
function (event) {
var element = event.target;
var resourceUrl =
element.tagName === "LINK" ? element.href : element.src;
if (!/^https:\/\/qqvip-web.cdn-go.cn/i.test(resourceUrl)) {
return;
}
var proxiedUrl = resourceUrl.replace(
/^https:\/\/qqvip-web.cdn-go.cn\//,
"https://zb.vip.qq.com/proxy/domain/qqvip-web.cdn-go.cn/"
);
if (window.hasReloadedScriptMap[proxiedUrl]) {
return;
}
switch (element.tagName) {
case "IMG":
element.src = proxiedUrl;
break;
case "LINK":
element.href = proxiedUrl;
break;
case "SCRIPT":
var newScript = document.createElement("script");
newScript.src = proxiedUrl;
newScript.async = element.async;
newScript.defer = element.defer;
newScript.crossOrigin = element.crossOrigin;
if (element.getAttribute("data-vue-meta")) {
newScript.setAttribute(
"data-vue-meta",
element.getAttribute("data-vue-meta")
);
}
newScript.onload = function () {
window.inReloadingScriptNumber--;
if (window.inReloadingScriptNumber === 0) {
var app =
window.rieApp.default || window.rieApp;
window.rieVue2Runtime.Vue.default.config.devtools = false;
window.rieVue2Runtime.init(app);
}
};
window.inReloadingScriptNumber++;
window.hasReloadedScriptMap[proxiedUrl] =
"reloaded";
element.parentNode.appendChild(newScript);
break;
}
},
true
);
window.__INITIAL_ASYNCDATA__={
"isHost": false,
"targetUin": "10000",
"isSvip": true,
"avatarImage": "https://q.qlogo.cn/g?b=qq&nk=10000&s=100",
"rawUsingList": [
{
"appId": 2,
"itemId": 2141485,
"name": "在说什么呢",
"image": "https://tianquan.gtimg.cn/bubble/item/2141485/newPreview1.png",
"extrainfo": { "price": 300 }
},
{
"appId": 15,
"itemId": 201534,
"name": "二次元少女",
"image": "https://tianquan.gtimg.cn/card/original/201534/templateThumb.jpg",
"extrainfo": {}
},
{
"appId": 22,
"itemId": 2000,
"name": "花瓣",
"image": "https://tianquan.gtimg.cn/colorScreen/item/2000/listImg.png",
"extrainfo": {}
},
{
"appId": 17,
"itemId": 2730,
"name": "岁月成碑",
"image": "https://tianquan.gtimg.cn/funcall/funCall/2730/web_image.jpg",
"extrainfo": {}
},
{
"appId": 4,
"name": "默认挂件",
"image": "https://tianquan.gtimg.cn/faceAddon/item/0/new1.png",
"extrainfo": {}
},
{
"appId": 23,
"name": "默认头像",
"image": "https://q1.qlogo.cn/qhis/FixtureAvatarHashRedacted/",
"extrainfo": {}
},
{
"appId": 47,
"name": "拍了拍",
"image": "https://tianquan.gtimg.cn/nudgeeffect/item/0/preview.png",
"extrainfo": {}
}
]
};(function(){})();
</script>
<title>好友装扮</title>
<link data-vue-meta="ssr" href="https://qqvip-web.cdn-go.cn/cdn/v1.7.3/legacy-style/gxh.vip.qq.com/storybook/src/css/vip-mall-global/global.css?_bid=5399" rel="stylesheet"><link data-vue-meta="ssr" href="https://qqvip-web.cdn-go.cn/cdn/v1.7.3/legacy-style/gxh.vip.qq.com/vipstyle/component/ui-tag-member-shop.css?_bid=5399" rel="stylesheet">
<script data-vue-meta="ssr">window.shouldOpenTestEnv = false;</script><script data-vue-meta="ssr" crossOrigin="anonymous" src="https://tam.cdn-go.cn/aegis-sdk/latest/aegis.min.js?_bid=5234"></script><script data-vue-meta="ssr" type="text/javascript" defer>
window.QQGXH_ENV = "dev";
window.version = "dev";
/* eslint-disable */
if (window.Aegis && !window.__aegis) {
var uinMatch = document.cookie.match(/uin=o(\d+)/);
var uin;
if (uinMatch.length === 2) {
uin = parseInt(uinMatch[1], 10);
}
var samplingReport = Math.random() < 0.1;
var appId = '';
if (window.location.pathname === '/mall/item-detail') {
var appIdRegExArray = window.location.href.match(/appid=(\d+)/i);
appId = appIdRegExArray ? appIdRegExArray[1] : '';
}
var qqversion = '9.3.5' || 'unknown';
var aegisConfig = {
id: '75w8vtQ8j2WjEb9bWd',
reportApiSpeed: samplingReport,
reportAssetSpeed: samplingReport,
version: window.version,
ext1: qqversion,
ext2: appId,
beforeRequest: function (data) {
var logMessage = data.logs.msg || '';
if (logMessage.indexOf('tianshu.qq.com') > -1 || logMessage.indexOf('h5.qzone.qq.com/report/action') > -1 || logMessage.indexOf('h.trace.qq.com') > -1 || logMessage.indexOf('report.qqweb.qq.com') > -1) {
return false;
}
if (logMessage.toLowerCase().indexOf('script error.') > -1 || logMessage.toLowerCase().indexOf('network error') > -1 || logMessage.toLowerCase().indexOf('request abort') > -1) {
return false;
}
}
};
if (uin) {
aegisConfig.uin = uin;
}
window.__aegis = new window.Aegis(aegisConfig);
function reportError() {
var Vue = window.rieVue2Runtime.Vue.default ? window.rieVue2Runtime.Vue.default : window.rieVue2Runtime.Vue;
if (Vue) {
Vue.config.errorHandler = function (error) {
console.error(error);
if (error instanceof Error) {
window.__aegis && window.__aegis.error(error);
}
};
}
}
document.addEventListener('DOMContentLoaded', reportError);
}
</script><script data-vue-meta="ssr" crossOrigin="anonymous" src="https://qqvip-web.cdn-go.cn/mono/latest/vendors/qqmobile/qqapi.wk.js?_bid=5234" defer></script><script data-vue-meta="ssr" crossOrigin="anonymous" defer src="https://qqvip-web.cdn-go.cn/setup/latest/index.js"></script>
<link rel="preload" href="https://qqvip-web.cdn-go.cn/qqgxh/latest//mall/ac38e282//client/mall/aio-dress/app.0246.css" as="style">
<link rel="stylesheet" href="https://qqvip-web.cdn-go.cn/qqgxh/latest//mall/ac38e282//client/mall/aio-dress/app.0246.css">
</head>
<body>
<script data-vue-meta="ssr" type="text/javascript" data-pbody="true">
/* eslint-disable */
(function () {
if (location.search.indexOf('bodyColor=transparent') > -1) {
document.body.style.backgroundColor = 'transparent';
} else {
var themeId = 0;
var themeRegex = navigator.userAgent.match(/QQTheme\/(\d+)/);
if (themeRegex) {
try {
themeId = parseInt(themeRegex[1], 10);
} catch (error) {}
}
if ([2920, 1102, 1103].indexOf(themeId) > -1) {
document.body.style.backgroundColor = '#000';
}
}
})();
/* eslint-disable */
// 修复页面元素因为rem错位问题的临时方案, 代码不经过转换,尽量保持兼容性。
(function () {
function getZoomFactor() {
var zoomFactor = 1;
if (isIOS()) {
return zoomFactor;
}
var declaredHTMLFontSize = document.documentElement.style.fontSize;
if (!isSizeValid(declaredHTMLFontSize)) {
return zoomFactor;
}
declaredHTMLFontSize = pixelToNumber(declaredHTMLFontSize);
var actualHTMLFontSize = getActualFontSize();
if (!isSizeValid(actualHTMLFontSize)) {
return zoomFactor;
}
if (Math.abs(declaredHTMLFontSize - actualHTMLFontSize) < 0.2) {
return zoomFactor;
}
return declaredHTMLFontSize / actualHTMLFontSize;
}
function isIOS() {
return /iPhone|iPad/.test(navigator.userAgent);
}
;
function pixelToNumber(pixel) {
return Number(pixel.replace('px', ''));
}
function isSizeValid(size) {
return /^\d+(\.\d+)?(px)?$/.test(size);
}
function getActualFontSize() {
var toolMan = document.createElement('div');
// offsetWidth会返回整数,直接设为1会丢失很大精度
toolMan.style.width = '10rem';
toolMan.style.position = 'absolute';
toolMan.style.left = '-10rem';
document.body.appendChild(toolMan);
var actualFontSize = toolMan.offsetWidth / 10;
toolMan.remove();
return actualFontSize;
}
// 设置设备当前应该使用的html font-size
function fixRem() {
// 设置默认二倍稿的宽高和默认设置html的font-size大小
var ALLOWED_MAX_ZOOM_FACTOR = 1.15;
var DEFAULT_FONT_SIZE = 100;
var DEFAULT_DEVICE_WIDTH = 750;
var DEFAULT_DEVICE_HEIGHT = 1334;
// 判断宽屏设备的最小高度
var MIN_DEVICE_HEIGHT = 610;
// 获取实际webview展示宽高
var html = document.querySelector('html');
var clientWidth = DEFAULT_DEVICE_WIDTH;
var clientHeight = DEFAULT_DEVICE_HEIGHT;
if (isIOS()) {
// ios中获取window.innerWidth和window.innerHeight有时候会不准确所以统一使用html.clientWidth
clientWidth = html.clientWidth || DEFAULT_DEVICE_WIDTH;
clientHeight = html.clientHeight || DEFAULT_DEVICE_HEIGHT;
} else {
clientWidth = window.innerWidth || html.clientWidth || DEFAULT_DEVICE_WIDTH;
clientHeight = window.innerHeight || html.clientHeight || DEFAULT_DEVICE_HEIGHT;
}
// 判断用户是否设置了系统缩放,导致实际设置的html font-size出现偏差,进行纠正
var zoomFactor = getZoomFactor();
var fixedHTMLFontSize = DEFAULT_FONT_SIZE * (clientWidth / DEFAULT_DEVICE_WIDTH) * zoomFactor;
/**
* 若满足一下条件之一,则视为宽屏设备
* 修正后的字体大小大于指定阈值并且高宽比小于1.4
* 屏幕高度大于610(避免因拉起输入框而误判)且屏幕高宽比小于1.2(经过对多款主流折叠屏手机分辨率计算得出)
*/
const largeScreenList = [fixedHTMLFontSize > DEFAULT_FONT_SIZE * ALLOWED_MAX_ZOOM_FACTOR && clientHeight / clientWidth < 1.4, clientHeight > MIN_DEVICE_HEIGHT && clientHeight / clientWidth < 1.2];
if (largeScreenList.some(Boolean)) {
// 当为宽屏设备时,考虑用两侧留白的方式恢复成窄屏样式。由于设计侧给出的浮层经常会达到1.5倍屏宽高度,这里取2倍
var widthFactor = clientHeight / 2 / DEFAULT_DEVICE_WIDTH;
html.style.padding = '0 ' + (clientWidth - DEFAULT_DEVICE_WIDTH * widthFactor) / 2 + 'px';
fixedHTMLFontSize = DEFAULT_FONT_SIZE * widthFactor;
} else {
html.style.padding = '';
}
html.style.fontSize = fixedHTMLFontSize + 'px';
}
;
window.addEventListener('load', fixRem);
window.addEventListener('resize', fixRem);
fixRem();
})();
</script>
<!-- 加载数据上报 vip-tracker -->
<script src="https://qqvip-web.cdn-go.cn/vip-tracker/latest/index.js?_bid=5234" crossorigin="anonymous"
defer></script>
<!--这个注释是rie用来插入内容渲染的!!!不能删!!!!-->
<div data-server-rendered="true" class="need-status-bar-height" data-v-66e2fb9e><div vt-appid="DressVip" vt-pageid="3001190" vt-busi="{&quot;op_result&quot;:2}" class="page-wrapper" data-v-094eb20e data-v-66e2fb9e><div vt-mdid="101" vt-expose="1" class="head-container" data-v-7bfa11be data-v-094eb20e><div class="title-box" data-v-7bfa11be><div class="title" data-v-7bfa11be>好友正在用</div><!----></div><div vt-itemid="go_zhuanqu" vt-itemtype="4" class="svip-box" data-v-7bfa11be><img src="https://qqvip-web.cdn-go.cn/qqgxh/latest//mall/ac38e282//client/img/penguin.a3db.png" class="penguin" data-v-7bfa11be><div class="content-box" data-v-7bfa11be><div class="pattern" data-v-7bfa11be></div><div class="background" data-v-7bfa11be></div><div class="text-box" data-v-7bfa11be><span data-v-7bfa11be>他是尊贵的SVIP,免费用7000多款装扮</span><div class="arrow" data-v-7bfa11be></div></div></div></div><div class="item-list" data-v-7bfa11be><div class="item-preview" data-v-0e6539b8 data-v-7bfa11be><div vt-sbmdid="1" vt-expose="1" data-v-0e6539b8><div vt-itemid="2141485" vt-itemtype="3001001" class="image-box" data-v-0e6539b8><div class="cubebox-item" data-v-5b8ee750 data-v-0e6539b8><div class="ui-discount-info ui-hippy" style="display:none;" data-v-5b8ee750><span data-v-5b8ee750></span></div><div accessibilityLabel="在说什么呢装扮图片" class="ui-cube-box-bubble-cube cube-size-square" style="background-image:linear-gradient(46deg, rgba(239, 212, 186, .5) 0%, rgba(239, 212, 186, .3) 100%);" data-v-0c9be67e data-v-5b8ee750><img src="https://tianquan.gtimg.cn/bubble/item/2141485/newPreview1.png" class="cube-size-square" data-v-0c9be67e><div class="cube-size-square cube-size-square-border" data-v-0c9be67e></div></div></div></div></div><div class="text-box" data-v-0e6539b8><div class="business-name" data-v-0e6539b8>
气泡
</div><div class="name" data-v-0e6539b8>在说什么呢</div></div><div vt-sbmdid="2" vt-expose="1" class="button-box" data-v-0e6539b8><div vt-itemid="2141485" vt-itemtype="3001001" class="button" data-v-0e6539b8>
用同款
</div></div></div><div class="item-preview" data-v-0e6539b8 data-v-7bfa11be><div vt-sbmdid="1" vt-expose="1" data-v-0e6539b8><div vt-itemid="201534" vt-itemtype="3001008" class="image-box" data-v-0e6539b8><div class="cubebox-item" data-v-5b8ee750 data-v-0e6539b8><div class="ui-discount-info ui-hippy" style="display:none;" data-v-5b8ee750><span data-v-5b8ee750></span></div><div accessibilityLabel="二次元少女装扮图片" class="ui-cube-box-card-cube cube-size-rectangle" data-v-5b8ee750><img src="https://tianquan.gtimg.cn/card/original/201534/templateThumb.jpg" class="cube-size-rectangle card-custom"><div class="cube-size-rectangle cube-size-rectangle-border"></div></div></div></div></div><div class="text-box" data-v-0e6539b8><div class="business-name" data-v-0e6539b8>
名片
</div><div class="name" data-v-0e6539b8>二次元少女</div></div><div vt-sbmdid="2" vt-expose="1" class="button-box" data-v-0e6539b8><div vt-itemid="201534" vt-itemtype="3001008" class="button" data-v-0e6539b8>
用同款
</div></div></div><div class="item-preview" data-v-0e6539b8 data-v-7bfa11be><div vt-sbmdid="1" vt-expose="1" data-v-0e6539b8><div vt-itemid="2000" vt-itemtype="3001112" class="image-box" data-v-0e6539b8><div class="cubebox-item" data-v-5b8ee750 data-v-0e6539b8><div class="ui-discount-info ui-hippy" style="display:none;" data-v-5b8ee750><span data-v-5b8ee750></span></div><div class="ui-cube-box-float-cube cube-size-square" style="background:linear-gradient(46deg, rgba(249, 200, 209, .5) 0%, rgba(249, 200, 209, .3) 100%);" data-v-204c96fb data-v-5b8ee750><div class="cube-size-square custom-float" style="background-image:url(https://tianquan.gtimg.cn/colorScreen/item/2000/listImg.png);" data-v-204c96fb></div><div class="cube-size-square cube-size-square-border" data-v-204c96fb></div></div></div></div></div><div class="text-box" data-v-0e6539b8><div class="business-name" data-v-0e6539b8>
浮屏
</div><div class="name" data-v-0e6539b8>花瓣</div></div><div vt-sbmdid="2" vt-expose="1" class="button-box" data-v-0e6539b8><div vt-itemid="2000" vt-itemtype="3001112" class="button" data-v-0e6539b8>
用同款
</div></div></div><div class="item-preview" data-v-0e6539b8 data-v-7bfa11be><div vt-sbmdid="1" vt-expose="1" data-v-0e6539b8><div vt-itemid="2730" vt-itemtype="3001013" class="image-box" data-v-0e6539b8><div class="cubebox-item" data-v-5b8ee750 data-v-0e6539b8><div class="ui-discount-info ui-hippy" style="display:none;" data-v-5b8ee750><span data-v-5b8ee750></span></div><div class="ui-cube-box-background" data-v-4ee6ef0e data-v-5b8ee750><span class="ic-face" data-v-782808e6 data-v-4ee6ef0e><img src="https://tianquan.gtimg.cn/funcall/funCall/2730/web_image.jpg" data-v-782808e6></span></div></div></div></div><div class="text-box" data-v-0e6539b8><div class="business-name" data-v-0e6539b8>
来电
</div><div class="name" data-v-0e6539b8>岁月成碑</div></div><div vt-sbmdid="2" vt-expose="1" class="button-box" data-v-0e6539b8><div vt-itemid="2730" vt-itemtype="3001013" class="button" data-v-0e6539b8>
用同款
</div></div></div><div class="item-preview" data-v-0e6539b8 data-v-7bfa11be><div vt-sbmdid="1" vt-expose="1" data-v-0e6539b8><div vt-itemid="0" vt-itemtype="3001011" class="image-box" data-v-0e6539b8><div class="cubebox-item" data-v-5b8ee750 data-v-0e6539b8><div class="ui-discount-info ui-hippy" style="display:none;" data-v-5b8ee750><span data-v-5b8ee750></span></div><div accessibilityLabel="默认挂件装扮图片" class="ui-cube-box-widget-cube cube-size-square" style="background-image:linear-gradient(46deg, rgba(230, 230, 230, .5) 0%, rgba(230, 230, 230, .3) 100%);" data-v-e853d2f4 data-v-5b8ee750><img src="https://q.qlogo.cn/g?b=qq&amp;nk=1707889225&amp;s=100&amp;timestamp=1784877299499" class="widget-face cube-size-square" style="border-radius:105px;" data-v-e853d2f4><img src="https://tianquan.gtimg.cn/faceAddon/item/0/new1.png" class="custom-widget cube-size-square square-img" data-v-e853d2f4><div class="cube-size-square cube-size-square-border" data-v-e853d2f4></div></div></div></div></div><div class="text-box" data-v-0e6539b8><div class="business-name" data-v-0e6539b8>
挂件
</div><div class="name" data-v-0e6539b8>默认挂件</div></div><div vt-sbmdid="2" vt-expose="1" class="button-box" data-v-0e6539b8><div vt-itemid="0" vt-itemtype="3001011" class="button stroke" data-v-0e6539b8>
去商城
</div></div></div><div class="item-preview" data-v-0e6539b8 data-v-7bfa11be><div vt-sbmdid="1" vt-expose="1" data-v-0e6539b8><div vt-itemid="0" vt-itemtype="3001017" class="image-box" data-v-0e6539b8><div class="cubebox-item" data-v-5b8ee750 data-v-0e6539b8><div class="ui-discount-info ui-hippy" style="display:none;" data-v-5b8ee750><span data-v-5b8ee750></span></div><div class="ui-cube-box-face-cube cube-size-square-small" style="background:linear-gradient(46deg, rgba(192, 234, 242, .5) 0%, rgba(192, 234, 242, .3) 100%);" data-v-7e24d472 data-v-5b8ee750><img src="https://q.qlogo.cn/g?b=qq&amp;nk=10000&amp;s=100" resizeMode="cover" class="cube-size-square" data-v-7e24d472><div class="cube-size-square cube-size-square-border" data-v-7e24d472></div></div></div></div></div><div class="text-box" data-v-0e6539b8><div class="business-name" data-v-0e6539b8>
头像
</div><div class="name" data-v-0e6539b8>自定义头像</div></div><div vt-sbmdid="2" vt-expose="1" class="button-box" data-v-0e6539b8><div vt-itemid="0" vt-itemtype="3001017" class="button stroke" data-v-0e6539b8>
去商城
</div></div></div></div><div vt-itemid="unfold" vt-itemtype="4" class="show-all-box" data-v-7bfa11be><div class="text" data-v-7bfa11be>更多</div><div class="icon" data-v-7bfa11be></div></div></div><!----><!----><div vt-mdid="102" vt-expose="1" class="recommend-container" data-v-094eb20e><div class="title-box" data-v-094eb20e><div class="title" data-v-094eb20e>热门推荐</div><div vt-itemtype="4" vt-itemid="go_mall" class="button-text" data-v-094eb20e>
去商城
</div></div><div class="recommend-tabs" data-v-b5f95dfc data-v-094eb20e><div vt-itemid="tab" vt-itemtype="3001001" class="tab-item active" data-v-b5f95dfc>
气泡
</div><div vt-itemid="tab" vt-itemtype="3001021" class="tab-item" data-v-b5f95dfc>
字体
</div><div vt-itemid="tab" vt-itemtype="3001011" class="tab-item" data-v-b5f95dfc>
挂件
</div><div vt-itemid="tab" vt-itemtype="3001008" class="tab-item" data-v-b5f95dfc>
名片
</div><div vt-itemid="tab" vt-itemtype="3001041" class="tab-item" data-v-b5f95dfc>
主题
</div><div vt-itemid="tab" vt-itemtype="3001004" class="tab-item" data-v-b5f95dfc>
背景
</div><div vt-itemid="tab" vt-itemtype="3001017" class="tab-item" data-v-b5f95dfc>
头像
</div><div vt-itemid="tab" vt-itemtype="3001013" class="tab-item" data-v-b5f95dfc>
来电
</div></div><div class="recommend-list-void" data-v-094eb20e><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAABkCAYAAABw4pVUAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAplSURBVHgB7V27dttGEB3ZKlIyXxDkHB9ZrqJ8QagyPn5IXbpQZSpZXTpTXyD5C0R16UQ/T1IZ/gLLnSUXgbukitLLdu4FZ5U1TOK5WIAk7jnrXVI0CezdmZ2dmV2IdOjQoUOHDh06dOiw8FiROcDW1lbw4cOH/srKSoDyzcePHwO8zdLTYuNCS8Qan3/z6dOn0+vXr0fj8fhUWo5WEqIEbKF5H2VDvuz0siBRJOUxCAI/40hahtYQAhJ6GPm7GM0DmYx+GxHKKf72HiOedbS6usr3JNmp/B5UvcvLS0pTD2UDn/9O62nf+6hN5DROCDqwD2l4iGbfvIfOo6oZg6BX2lkX4gBG9fG38P0/JAgKUR49ffp0LA2iMUKSRBgS8N7xs2fPQvGAO3fukJgBmj9bb0co+yBmJA3AOyHTiIAkPIIKOnQlCSWuyRgNDy2piSCdO7imUDzCGyHU7bjpIzbjHwYRuPm9pkbiLNy9e3eQIGYEYvZ9zTFeCMFNkgSS0WuDROQB1NmQxOjLSDypsVoJUcuJo+2BvhWqGohkDqCqbCj/zzGHKi21DaTaCNGbeYkmzc8LtPefP39+KHMISPgDVWM0qTm3bNY1qGohBGRsKBlUUdG1a9c250UqZoEDDNL+UueWCPe3/eLFC+cr/2viGPfu3fvZkIEyBhnfzzsZBO+B98ImSgApecl7FcdwKiG8QIygEduoH2E98UAWEPaEz3XMkydPjsURrosj2GTgImmR/CoLivPz83BtbQ23udLHy6319fXo7OzsjTiAE0I4Z0C//obmVyQDI2YoC44EKf0bN2788e7du7+kIiqrrIQ1tRRk2ID6OsR976J5gXml8nxZiRBdfb+WiXd2DDW1LUsImMUnMvFAREpK6XVKJSuLiz6ZSEbs95ElBe+dfYBmoH660igtIfT5oDriom9RTNsq0HXKa108bpd145eSEP44qngkcAW+7GQQ7AOQsa8vjzRQVhilCFGxDFBGbXCHQFo/sUjDgFSwL0IU49kujMKEMKiDasA2HW3S4TPofMJJfYuxHymIwoTgx460rl1VYbG5i1JpkrTBec/l900D+4ThBbbLTPCFCNGJPLaq6l5vcLEJnXyIMiwz0qZ8X4CKHtuh3kdtYKxHpaRf9NqLSkjMuDV51QbmUNEfxjb1cdlJ0kB1eoAyqjvQxHUIo6H6u4WkJDchGvWLpcNX2FWdk6FM7PtSkyRB1SeTTJPI17zHPiojJUUkhDflRTps2JMkA0VSEFRVVH1s89p9muhl5pJchKj+7bONDgrFI9S+39OXD/VackP9bHE4wHdCRWIuyaVycxGiaZ3EqIlFIDtS5xNmJJ4kbw5/X2FJ/j+Y6FeuHXTOUDxDfVqP2Ya05JLuvCorVleQDmeBmKJghzKNFM29As67mCS4drabynABESPWGFC5oouZvix1r/+ppu63MmegNDWdbgSj4h/6uDCgv83SMJkSYtQVvjCUOURLcr9itWWp/pnIo7Lua/1KOpSCNZjvZ302kxCm8bP2bV0tEpjBr82NrM+mziGaX/Xa9/yhCdnxYk7cbdYxoAoLUY59bj3AGupPmaQPpc4jq2lfgk4JWEPknGRUZMEkZOfRtRVAgvn9XGgykXrP0zxDC9HsTxnN+lAqIbrrSNTcrB1YY7zkb1oJ2c7XPYmtBwP85gbe26ybFPzee+3LIO1zqYRwK5jWtRMC0/AAv7NhUk+hIiOpAUrwCCSETA1Fm2r5AHWtOQGmD7lpNe1zWZN6rL8h1rWOHq6omSGv8XkvecCaGrqpro3a4yTcF8ladxDPRBYhgdaR1ASSgU4Zso2L3fbpmtFgUpy6pHGSws7LvDCbVOXLDa2fIZUQ7mLVZi0SQpe+Rcaer72FNvQ3jfPyQMMMdSLVakwlRFNaalntqtf2KhzcZLIEkxPsjJHbt29nrheKwpL88oTUBSv9tEcvbhvSTyEpQ+NRxpx5UtTN7wqr0gBMLjDbzIuFmtjN8d8uMJK/loKw0jyLwAwY787URiREMia2GeiVTHYoq34CaQBZC0MG69kRQR3Wz7Sg0jSYDTIYtYwphJITiSyZ3KO9jqQ79UKwmTofZ03qbXBd26HQQV4ryE539Z0HMAO5LNYslRVpHUiD0LSaKysoixR7zwpK2IbDCXgYjjajtM9lrUPeszZOxiZhmaYcaScg5Sg5p5AIrrjNnpU2bZOw1nT/pn0uy8qK+A99TNIC0DTFfCK64XKAjqcK458imSQ42zY+dwDvtOW0iLyO2qw5JNIvC6QlICmMKaB5bN1cIHpsB0hghsomd3O16eiOvI7aVAlhlFAtg++kRVCLb8C2ObDMer+tMJHXKO1DqYTwBqGTOaEGbcjemAa9ptZdlw01MgI0L7LOfcxcGBoRqzmKt9DQKCGRGVfKs1KPU1igm3+QDmVh+u5x1gczCTEZE3CPdxJSHn3+Y2WfzEQmITpRspT1JS01dAtgvCbKY3Tkci5iHjnW2unpN1U34cwDQETcZ2bzURZyEUJfEmuqLUedGGrdigWnDeOWcZFpo/60Adt51BWRixA1LUOUXt60+jRgtMRpqS62qrmEXgszUHKP6DRY1lWYd42UOx5inHuo8wSTUqHe20gmgaDXHuLYqSARmi155QNz5JA0mSy5yS10tAY6jh7UPspO1QtOHJnXGrg6ktA6eqRQLKZQxNBygR9UVTW8Yb3QHV+ZkRkIeX8Oz20pFYspfPiMkZJlPBsrL0yuWZkk9cIxdXsuaSozo81gn5hcM7r/pSAKE6KJZTThSh+wssiwtkCPypwbXyrrxNo73q8z/XLeoAcUDKocUFB4DjFQU5U5T07OGpx3qIudZjONndJWaOm8LO4+Mpl+TChYBjfILGiKz1UmZpUlQaVEOd07HknFs0jmHeZgGxcHFFQihC4Va48Ft4gdyJJBT4vYshaUlaKXlQ9Sfvv27cWtW7f+QPMnlP76+rqcnZ0txRZqa73BgfkjyHgrFeHkZGuQ8tfa2trfMklqXgpS7I1GwC9YAP4uDuDs7Pfz8/PTmzdvMrFu4UnhfkhU5mz7HZeZkaXN3lnQZzgd6GafsT5Rp9VZIXlhP0errmdoOSeE0MP5T8zDT+p8Io0vJJ8YpBO4c6doLftDeKFqfUXyf8xjblf0XIHbsRL1CNfioa5FQgwo4peXl0N9egDh9RF0VaFSQRXV52su+rjOmMuHgtlIPhuQ1gmskjbs2ZgK67m8lOqezhc7Ps5G8UIIMeURdJE0+IjTWdBIH60o4wryaph4I8SAeUrQwUf2I05R9pnY3ZQqS0qEvh1HEH3vnfdOiMGUR5wSnGOOx56eP8vEBuaaaVZmo0QYNEaIgbrxzdlYBpFM0o5euZQcXUdsMU85QQLRKBEGjRNioHMMF1y7Mx5Ef4q/vWE2vh6Gw/cukrrdCiubLQDc28J6Q77cK8kzgY/b9Fze1hBiw5CD5n3dCuYk1qLWEtcPj5lJ2Ebzu5WEJKFHDQZKDkc8CeLrXpIs7fRYgqCaKAE8OCxq0mjo0KFDhw4dOnTo0KHDZ/gPeuE7Mm+hz58AAAAASUVORK5CYII=" class="void-img" data-v-094eb20e><div class="void-tips" data-v-094eb20e>
数据加载中
</div><!----></div></div><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADQAAAA0CAMAAADypuvZAAAAclBMVEUAAAAiIiIRERESEhITExMKCgoMDAz////8/Pz8/Pz+/v709PSJiYnv7+/Gxsb4+Pj8/Pz29vb7+/v8/Pzx8fH6+vrZ2dnu7u62trbd3d36+vr6+vr8/Pz6+vrm5ub19fWqqqr///9NTU3p6eljY2OxsbFeuYADAAAAIXRSTlMABQoGCA0Q8NLi4ZceeBW0sqaikoiDS0UtJXLDwZNqZBh6igpAAAABnklEQVRIx9XSa7OCIBAG4BZQ0LKLealOl4Pm//+LBzjjLLYqfO2dqQ/BM++y0+YrA+NXvGhvx1xqLdWxbuPIvpbaS15eIUjOmqS8rpsbtvhtrxUCYw3JA5bI/q4Xo/bzjCu9kjvMmodezXlGwUsHcgNirnkISfIsXupgzhw+ivCs+wie/MLEiDIG1XyKch0RKfwq3pIL/fvdkx9bjgp4TU3XUVV4VZwdZsyMOiICLhQxtomoXHCvSRLTd11PlGQ+okabXVOFCASjxiKqmMA3MUmMRURJJgBRhgeDvTYiqwY8Ux4Sk5UP1jjk1OCvHNFGsEKTGERSTbbXxKFmghIZg7JEIAKRVDHoZJ+EiO1i0MVNhztPtmF0MtO5JqySOpDsMv4fcBVFCD0TO50fYQdczTbBNeAC0581o1IsQsSSnVo2PztjTBFV6XZxttQNR5BTz2yOyMIYHI50XU4zNTvbg8MRZdmkTVaGkNmmi7csbaqDkuZ+diia1BEOywj4P8NYYswSGJlxCcYK8hqqTJsJcxGErNXZCPOhIly6+cr8AWSCpSyWFyd6AAAAAElFTkSuQmCC" class="up-top" style="display:none;" data-v-094eb20e><!----><!----><!----><div vt-mdid="101" data-v-094eb20e><div vt-itemid="mine" vt-itemtype="4" data-v-094eb20e></div><div vt-itemid="show_set" vt-itemtype="4" data-v-094eb20e></div></div></div></div>
<script src="https://qqvip-web.cdn-go.cn/qqgxh/latest//mall/ac38e282//client/rie.vue2.runtime.b4d6.js" crossorigin="anonymous" defer></script><script src="https://qqvip-web.cdn-go.cn/qqgxh/latest//mall/ac38e282//client/mall/aio-dress/app.74a5.js" crossorigin="anonymous" defer></script>
<script>window.__INITIAL_ASYNCDATA__={"isHost":false,"targetUin":"10000","rawUsingList":[{"images":[],"appId":2,"itemId":2141485,"name":"在说什么呢","feeType":49,"itemBgColor":"dbcab1","image":"https:\u002F\u002Ftianquan.gtimg.cn\u002Fbubble\u002Fitem\u002F2141485\u002FnewPreview1.png","extrainfo":{"price":300,"sourceId":"1112308884"},"extraappinfo":{"multOperationType":[],"extraInfo":{"extQualDay":"0","showGif":"0","bubbleGroup":"0","immersiveMaterial":"{\"zoomPointX\":57,\"zoomPointY\":56,\"color\":\"0xFF000000\",\"staticTopLeft\":\"https:\u002F\u002Ftianquan.gtimg.cn\u002Fimmersive\u002Fbubble\u002F2141485\u002Fstatic-top-left-v2.png\",\"staticTopRight\":\"https:\u002F\u002Ftianquan.gtimg.cn\u002Fimmersive\u002Fbubble\u002F2141485\u002Fstatic-top-right-v2.png\",\"staticBottomLeft\":\"https:\u002F\u002Ftianquan.gtimg.cn\u002Fimmersive\u002Fbubble\u002F2141485\u002Fstatic-bottom-left-v2.png\",\"staticBottomRight\":\"https:\u002F\u002Ftianquan.gtimg.cn\u002Fimmersive\u002Fbubble\u002F2141485\u002Fstatic-bottom-right-v2.png\",\"staticTopMiddle\":\"https:\u002F\u002Ftianquan.gtimg.cn\u002Fimmersive\u002Fbubble\u002F2141485\u002Fstatic-top-middle-v2.png\",\"staticLeftMiddle\":\"https:\u002F\u002Ftianquan.gtimg.cn\u002Fimmersive\u002Fbubble\u002F2141485\u002Fstatic-left-middle-v2.png\",\"staticBottomMiddle\":\"https:\u002F\u002Ftianquan.gtimg.cn\u002Fimmersive\u002Fbubble\u002F2141485\u002Fstatic-bottom-middle-v2.png\",\"staticRightMiddle\":\"https:\u002F\u002Ftianquan.gtimg.cn\u002Fimmersive\u002Fbubble\u002F2141485\u002Fstatic-right-middle-v2.png\",\"staticAllMiddle\":\"https:\u002F\u002Ftianquan.gtimg.cn\u002Fimmersive\u002Fbubble\u002F2141485\u002Fstatic-all-middle-v2.png\",\"staticAll\":\"https:\u002F\u002Ftianquan.gtimg.cn\u002Fimmersive\u002Fbubble\u002F2141485\u002Fstatic-all.png\"}","isKuikly":"1","bubbleType":"0","platformId":"0","isDiy":"0","isAiContent":"false","diyTextPos":"0","cornType":"0","isWithNotificationIcon":"0","vipLevel":"0","isLinkage":"0","showGifNew":"0"},"validDay":31}},{"images":[],"appId":15,"itemId":201534,"name":"二次元少女","feeType":5,"itemBgColor":"7c96c1","image":"https:\u002F\u002Ftianquan.gtimg.cn\u002Fcard\u002Foriginal\u002F201534\u002FtemplateThumb.jpg","extrainfo":{},"extraappinfo":{"multOperationType":[],"extraInfo":{"defaultColor":"2","isDiy":"0"}}},{"images":[],"appId":22,"itemId":2000,"name":"花瓣","feeType":5,"itemBgColor":"f7c8d0","image":"https:\u002F\u002Ftianquan.gtimg.cn\u002FcolorScreen\u002Fitem\u002F2000\u002FlistImg.png","extrainfo":{},"extraappinfo":{"multOperationType":[],"extraInfo":{}}},{"images":[],"appId":17,"itemId":2730,"name":"岁月成碑","feeType":5,"itemBgColor":"f9e7e5","image":"https:\u002F\u002Ftianquan.gtimg.cn\u002Ffuncall\u002FfunCall\u002F2730\u002Fweb_image.jpg","extrainfo":{},"extraappinfo":{"multOperationType":[],"extraInfo":{}}},{"images":[],"appId":4,"name":"默认挂件","feeType":1,"itemBgColor":"f2f2f2","image":"https:\u002F\u002Ftianquan.gtimg.cn\u002FfaceAddon\u002Fitem\u002F0\u002Fnew1.png","extrainfo":{},"isSetup":1,"extraappinfo":{"multOperationType":[],"extraInfo":{"isDiy":"0"}}},{"images":[],"appId":23,"name":"默认头像","feeType":1,"itemBgColor":"00cafc","image":"https:\u002F\u002Fq1.qlogo.cn\u002Fqhis\u002FFixtureAvatarHashRedactedxxxxxxxxxxxxxxxxxxxx\u002F","extrainfo":{},"isSetup":1,"extraappinfo":{"multOperationType":[],"extraInfo":{}}},{"images":[],"appId":47,"name":"拍了拍","feeType":1,"itemBgColor":"9da1b2","image":"https:\u002F\u002Ftianquan.gtimg.cn\u002Fnudgeeffect\u002Fitem\u002F0\u002Fpreview.png","extrainfo":{},"extraappinfo":{"multOperationType":[],"extraInfo":{}}}],"isSvip":true,"avatarImage":"https:\u002F\u002Fq.qlogo.cn\u002Fg?b=qq&nk=10000&s=100","usingList":[{"item":{"images":[],"appId":2,"itemId":2141485,"name":"在说什么呢","feeType":49,"itemBgColor":"dbcab1","image":"https:\u002F\u002Ftianquan.gtimg.cn\u002Fbubble\u002Fitem\u002F2141485\u002FnewPreview1.png","extrainfo":{"price":300,"sourceId":"1112308884"},"extraappinfo":{"multOperationType":[],"extraInfo":{"extQualDay":"0","showGif":"0","bubbleGroup":"0","immersiveMaterial":"{\"zoomPointX\":57,\"zoomPointY\":56,\"color\":\"0xFF000000\",\"staticTopLeft\":\"https:\u002F\u002Ftianquan.gtimg.cn\u002Fimmersive\u002Fbubble\u002F2141485\u002Fstatic-top-left-v2.png\",\"staticTopRight\":\"https:\u002F\u002Ftianquan.gtimg.cn\u002Fimmersive\u002Fbubble\u002F2141485\u002Fstatic-top-right-v2.png\",\"staticBottomLeft\":\"https:\u002F\u002Ftianquan.gtimg.cn\u002Fimmersive\u002Fbubble\u002F2141485\u002Fstatic-bottom-left-v2.png\",\"staticBottomRight\":\"https:\u002F\u002Ftianquan.gtimg.cn\u002Fimmersive\u002Fbubble\u002F2141485\u002Fstatic-bottom-right-v2.png\",\"staticTopMiddle\":\"https:\u002F\u002Ftianquan.gtimg.cn\u002Fimmersive\u002Fbubble\u002F2141485\u002Fstatic-top-middle-v2.png\",\"staticLeftMiddle\":\"https:\u002F\u002Ftianquan.gtimg.cn\u002Fimmersive\u002Fbubble\u002F2141485\u002Fstatic-left-middle-v2.png\",\"staticBottomMiddle\":Line truncated
<script>
document.addEventListener('DOMContentLoaded', function() {
var app = window.rieApp.default || window.rieApp;
window.rieVue2Runtime.Vue.default.config.devtools = false;
window.rieVue2Runtime.init(app);
});
</script>
<script>window._HTML_END_TIMESTAMP_ = Date.now();</script>
</body>
</body>
</html>
@@ -31,7 +31,7 @@ describe('friend-dress / real sample parsing', () => {
const request = mockHtml(SAMPLE_HTML);
await getFriendDressWebAPI(cookies, '10000');
const [url, method, , headers] = request.mock.calls[0]!;
const [url, method, , headers, limits] = request.mock.calls[0]!;
expect(url).toContain('https://zb.vip.qq.com/v2/pages/aioDressPage?');
expect(url).toContain('targetUin=10000');
// traceDetail 是预编码的 base64 串,必须原样出现(不能被二次编码成 base64%2D…)。
@@ -41,6 +41,10 @@ describe('friend-dress / real sample parsing', () => {
Cookie: 'uin=o10001; skey=SKEY; p_uin=o10001; p_skey=PSKEY',
});
expect((headers as Record<string, string>)['User-Agent']).toContain('QQ/');
expect(limits).toEqual({
timeoutMs: 10_000,
maxResponseBytes: 2 * 1024 * 1024,
});
});
it('parses the real page: svip, avatar, and only resolvable dress items', async () => {
@@ -107,23 +111,16 @@ describe('friend-dress / synthetic payloads', () => {
expect(dress.items[0]!.preview_url).toBe('https://cdn.example/funCall/1/preview.png');
});
it('extracts the card video from immersiveMaterial and survives broken JSON there', async () => {
it('extracts the card video from immersiveMaterial', async () => {
mockHtml(wrapHtml({
...base,
rawUsingList: [
{
appId: 15, itemId: 1, name: 'a', image: 'https://cdn.example/a.jpg',
extraappinfo: { extraInfo: { immersiveMaterial: '{"videoUrl":"https://cdn.example/a.mp4"}' } },
},
{
appId: 15, itemId: 2, name: 'b', image: 'https://cdn.example/b.jpg',
extraappinfo: { extraInfo: { immersiveMaterial: '{not json' } },
},
],
rawUsingList: [{
appId: 15, itemId: 1, name: 'a', image: 'https://cdn.example/a.jpg',
extraappinfo: { extraInfo: { immersiveMaterial: '{"videoUrl":"https://cdn.example/a.mp4"}' } },
}],
}));
const dress = await getFriendDressWebAPI(cookies, '10000');
expect(dress.items[0]!.video_url).toBe('https://cdn.example/a.mp4');
expect(dress.items[1]!.video_url).toBe('');
});
it('labels unknown appIds without dropping them', async () => {
@@ -167,10 +164,46 @@ describe('friend-dress / error classification', () => {
await expectKind('10000', 'parse');
});
it('structure: malformed immersiveMaterial is not silently discarded', async () => {
mockHtml(wrapHtml({
targetUin: '10000',
rawUsingList: [{
appId: 15,
itemId: 2,
name: 'broken',
image: 'https://cdn.example/b.jpg',
extraappinfo: { extraInfo: { immersiveMaterial: '{not json' } },
}],
}));
const e = await expectKind('10000', 'structure');
expect(e.message).toContain('immersiveMaterial');
});
it.each([
['not a string', { videoUrl: 'https://cdn.example/video.mp4' }],
['an array', '[]'],
['missing videoUrl', '{}'],
['non-string videoUrl', '{"videoUrl":42}'],
])('structure: immersiveMaterial %s is not silently discarded', async (_label, material) => {
mockHtml(wrapHtml({
targetUin: '10000',
rawUsingList: [{
appId: 15,
itemId: 2,
name: 'broken',
image: 'https://cdn.example/b.jpg',
extraappinfo: { extraInfo: { immersiveMaterial: material } },
}],
}));
const e = await expectKind('10000', 'structure');
expect(e.message).toContain('immersiveMaterial');
});
it.each([
['rawUsingList missing', { targetUin: '10000' }],
['rawUsingList not an array', { targetUin: '10000', rawUsingList: 'nope' }],
['item not an object', { targetUin: '10000', rawUsingList: ['nope'] }],
['item appId missing', { targetUin: '10000', rawUsingList: [{}] }],
['item appId not a number', { targetUin: '10000', rawUsingList: [{ appId: 'four' }] }],
['targetUin not a string', { targetUin: 10000, rawUsingList: [] }],
])('structure: %s', async (_label, payload) => {
@@ -185,9 +218,9 @@ describe('friend-dress / error classification', () => {
expect(e.message).toContain('10000');
});
it('tolerates a missing targetUin by echoing the requested uin', async () => {
it('structure: targetUin missing cannot prove which account owns the response', async () => {
mockHtml(wrapHtml({ rawUsingList: [] }));
const dress = await getFriendDressWebAPI(cookies, '10000');
expect(dress.target_uin).toBe('10000');
const e = await expectKind('10000', 'structure');
expect(e.message).toContain('targetUin');
});
});
@@ -0,0 +1,255 @@
import http from 'node:http';
import type { AddressInfo } from 'node:net';
import { afterEach, describe, expect, it } from 'vitest';
import { RequestUtil } from '@snowluma/protocol/web/request-util';
const servers = new Set<http.Server>();
async function serve(
handler: http.RequestListener,
): Promise<{ server: http.Server; url: string }> {
const server = http.createServer(handler);
servers.add(server);
await new Promise<void>((resolve, reject) => {
server.once('error', reject);
server.listen(0, '127.0.0.1', resolve);
});
const address = server.address() as AddressInfo;
return { server, url: `http://127.0.0.1:${address.port}` };
}
afterEach(async () => {
await Promise.all([...servers].map(async (server) => {
server.closeAllConnections();
await new Promise<void>((resolve) => server.close(() => resolve()));
servers.delete(server);
}));
});
describe('RequestUtil bounded text responses', () => {
it('rejects a response once it exceeds the byte limit', async () => {
const { url } = await serve((_req, res) => {
res.end('x'.repeat(65));
});
await expect(RequestUtil.HttpGetText(
url,
'GET',
undefined,
{},
{ maxResponseBytes: 64 },
)).rejects.toThrow('response body exceeds 64 bytes');
});
it('rejects a request that does not complete before its deadline', async () => {
const { url } = await serve((_req, res) => {
res.writeHead(200);
res.write('partial');
});
await expect(RequestUtil.HttpGetText(
url,
'GET',
undefined,
{},
{ timeoutMs: 30 },
)).rejects.toThrow('request timed out after 30 ms');
});
it('measures the response limit in bytes and accepts the exact boundary', async () => {
const exact = '界'.repeat(16);
const { url } = await serve((_req, res) => {
res.end(exact);
});
await expect(RequestUtil.HttpGetText(
url,
'GET',
undefined,
{},
{ maxResponseBytes: Buffer.byteLength(exact) },
)).resolves.toBe(exact);
});
it('rejects a multibyte response that exceeds the byte boundary', async () => {
const tooLarge = '界'.repeat(17);
const { url } = await serve((_req, res) => {
res.end(tooLarge);
});
await expect(RequestUtil.HttpGetText(
url,
'GET',
undefined,
{},
{ maxResponseBytes: 48 },
)).rejects.toThrow('response body exceeds 48 bytes');
});
it('closes a non-success response without waiting for its body to end', async () => {
let markClosed!: () => void;
const closed = new Promise<void>((resolve) => { markClosed = resolve; });
const { url } = await serve((_req, res) => {
res.once('close', markClosed);
res.writeHead(403);
res.flushHeaders();
res.write('body that never ends');
});
await expect(RequestUtil.HttpGetText(url)).rejects.toThrow('Unexpected status code: 403');
await expect(Promise.race([
closed.then(() => true),
new Promise<boolean>((resolve) => setTimeout(() => resolve(false), 250)),
])).resolves.toBe(true);
});
});
describe('RequestUtil redirects', () => {
it('strips credentials when a redirect crosses origins', async () => {
let redirectedHeaders: http.IncomingHttpHeaders | undefined;
const target = await serve((req, res) => {
redirectedHeaders = req.headers;
res.end('ok');
});
const source = await serve((_req, res) => {
res.writeHead(302, { location: target.url });
res.end();
});
await expect(RequestUtil.HttpGetText(
source.url,
'GET',
undefined,
{
Cookie: 'uin=secret',
Authorization: 'Bearer secret',
'Proxy-Authorization': 'Basic secret',
'X-SnowLuma-Test': 'kept',
},
)).resolves.toBe('ok');
expect(redirectedHeaders?.cookie).toBeUndefined();
expect(redirectedHeaders?.authorization).toBeUndefined();
expect(redirectedHeaders?.['proxy-authorization']).toBeUndefined();
expect(redirectedHeaders?.['x-snowluma-test']).toBe('kept');
});
it('never forwards a write request body across origins', async () => {
let targetReached = false;
const target = await serve((_req, res) => {
targetReached = true;
res.end('unexpected');
});
const source = await serve((_req, res) => {
res.writeHead(307, { location: target.url });
res.end();
});
await expect(RequestUtil.HttpGetText(
source.url,
'POST',
'secret-body',
{ 'Content-Type': 'text/plain' },
)).rejects.toThrow('cross-origin redirect cannot forward method POST');
expect(targetReached).toBe(false);
});
it('preserves credentials for same-origin redirects', async () => {
let redirectedCookie: string | undefined;
const { url } = await serve((req, res) => {
if (req.url === '/start') {
res.writeHead(302, { location: '/finish' });
res.end();
return;
}
redirectedCookie = req.headers.cookie;
res.end('ok');
});
await expect(RequestUtil.HttpGetText(
`${url}/start`,
'GET',
undefined,
{ Cookie: 'uin=same-origin' },
)).resolves.toBe('ok');
expect(redirectedCookie).toBe('uin=same-origin');
});
it('inherits response limits after a redirect', async () => {
const target = await serve((_req, res) => {
res.end('x'.repeat(65));
});
const source = await serve((_req, res) => {
res.writeHead(302, { location: target.url });
res.end();
});
await expect(RequestUtil.HttpGetText(
source.url,
'GET',
undefined,
{},
{ maxResponseBytes: 64 },
)).rejects.toThrow('response body exceeds 64 bytes');
});
it('shares one wall-clock deadline across the redirect chain', async () => {
const target = await serve((_req, res) => {
setTimeout(() => res.end('late'), 80);
});
const source = await serve((_req, res) => {
setTimeout(() => {
res.writeHead(302, { location: target.url });
res.end();
}, 80);
});
await expect(RequestUtil.HttpGetText(
source.url,
'GET',
undefined,
{},
{ timeoutMs: 100 },
)).rejects.toThrow('request timed out after 100 ms');
});
it('rejects malformed redirect locations instead of throwing outside the Promise', async () => {
const { url } = await serve((_req, res) => {
res.writeHead(302, { location: 'http://[' });
res.end();
});
await expect(RequestUtil.HttpGetText(url)).rejects.toThrow('invalid redirect location');
});
it('rejects redirects to non-HTTP protocols', async () => {
const { url } = await serve((_req, res) => {
res.writeHead(302, { location: 'file:///tmp/not-a-web-response' });
res.end();
});
await expect(RequestUtil.HttpGetText(url)).rejects.toThrow(
'unsupported redirect protocol: file:',
);
});
it('closes the previous response before following a redirect', async () => {
const target = await serve((_req, res) => {
res.end('ok');
});
let markClosed!: () => void;
const closed = new Promise<void>((resolve) => { markClosed = resolve; });
const source = await serve((_req, res) => {
res.once('close', markClosed);
res.writeHead(302, { location: target.url });
res.flushHeaders();
res.write('body that never ends');
});
await expect(RequestUtil.HttpGetText(source.url)).resolves.toBe('ok');
await expect(Promise.race([
closed.then(() => true),
new Promise<boolean>((resolve) => setTimeout(() => resolve(false), 250)),
])).resolves.toBe(true);
});
});