Skip to content

Commit

Permalink
refactor: set max_text_len = 15120
Browse files Browse the repository at this point in the history
  • Loading branch information
avwo committed Feb 21, 2023
1 parent c458fbe commit 44ada1f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 16 deletions.
16 changes: 7 additions & 9 deletions lib/plugins/whistle.nohost/lib/accountMgr.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ const CRLF_RE = /\s*[\r\n]+\s*/g;
const CONFIG_RE = /^([\w-]{1,64}:?|[\w.-]{1,64}:)(?:\s+([\w.:/-]*[\w-]))?$/mg;
const ACCOUNT_NAME_VAR = /\$\{name\}/g;
const VAR_RE = /\$\{([\w.]+)\}/g;
const JSON_DATA_LEN = 30720;
const RULES_TPL_LEN = 3072;
const DEFAULT_RULES_LEN = 5120;
const MAX_TEXT_LEN = 1512 * 10;
const NOHOST_VAR_RE = /^nohost_\w+$/;
const AUTH_KEY_RE = /^[\w.@-]{1,32}$/;
const SPECIAL_CHAR_RE = /[.$]/g;
Expand Down Expand Up @@ -390,7 +388,7 @@ class AccountMgr {

setJsonData(str) {
str = getString(str);
if (str.length > JSON_DATA_LEN) {
if (str.length > MAX_TEXT_LEN) {
return;
}
this.parseJsonData(str);
Expand All @@ -400,7 +398,7 @@ class AccountMgr {

setRulesTpl(str) {
str = getString(str);
if (str.length > RULES_TPL_LEN) {
if (str.length > MAX_TEXT_LEN) {
return;
}
storage.setProperty('rulesTpl', str);
Expand All @@ -409,7 +407,7 @@ class AccountMgr {

setEntryPatterns(str) {
str = getString(str);
if (str.length > DEFAULT_RULES_LEN) {
if (str.length > MAX_TEXT_LEN) {
return;
}
storage.setProperty('entryPatterns', str);
Expand All @@ -418,7 +416,7 @@ class AccountMgr {

setDefaultRules(str) {
str = getString(str);
if (str.length > DEFAULT_RULES_LEN) {
if (str.length > MAX_TEXT_LEN) {
return;
}
storage.setProperty('defaultRules', str);
Expand All @@ -435,7 +433,7 @@ class AccountMgr {

setAccountRules(str) {
str = getString(str);
if (str.length > DEFAULT_RULES_LEN) {
if (str.length > MAX_TEXT_LEN) {
return;
}
storage.setProperty('accountRules', str);
Expand All @@ -444,7 +442,7 @@ class AccountMgr {

setTestRules(str) {
str = getString(str);
if (str.length > DEFAULT_RULES_LEN) {
if (str.length > MAX_TEXT_LEN) {
return;
}
storage.setProperty('testRules', str);
Expand Down
13 changes: 7 additions & 6 deletions src/admin/config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import WhistleEditor from '../../components/whistleEditor';
import Tabs from '../../components/tab';
import './index.css';

const MAX_TEXT_LEN = 1512 * 10;
const DEFAULT_RE = '/^\\s*([\\w-]{1,64}:?|[\\w.-]{1,64}:)\\s+([\\w.:/-]*[\\w-])\\s*$/m';
const REG_EXP_RE = /^\s*\+?\/(.+)\/([ium]{0,3})\s*$/;
const { TabPane } = Tabs;
Expand Down Expand Up @@ -256,7 +257,7 @@ class Config extends Component {
title={WHITE_REQ_TITLE}
value={entryPatterns}
handleSave={this.setEntryPatterns}
maxLength="5120"
maxLength={MAX_TEXT_LEN}
ref={ref => {
this.entryPatternsPanel = ref;
}}
Expand All @@ -278,7 +279,7 @@ class Config extends Component {
title={ACCOUNT_RULES_TITLE}
value={accountRules}
handleSave={this.setAccountRules}
maxLength="5120"
maxLength={MAX_TEXT_LEN}
ref={ref => {
this.accountRulesPanel = ref;
}}
Expand All @@ -288,7 +289,7 @@ class Config extends Component {
title={DEFAULT_RULES_TITLE}
value={defaultRules}
handleSave={this.setDefaultRules}
maxLength="5120"
maxLength={MAX_TEXT_LEN}
ref={ref => {
this.defaultRulesPanel = ref;
}}
Expand All @@ -298,7 +299,7 @@ class Config extends Component {
title={SPECIAL_RULES_TITLE}
value={testRules}
handleSave={this.setTestRules}
maxLength="5120"
maxLength={MAX_TEXT_LEN}
settingsBtn="设置匹配条件"
onClickSettings={this.editSpecSettings}
ref={ref => {
Expand All @@ -322,7 +323,7 @@ class Config extends Component {
title={TPL_TITLE}
value={rulesTpl}
handleSave={this.setRulesTpl}
maxLength="3072"
maxLength={MAX_TEXT_LEN}
ref={ref => {
this.rulesTplPanel = ref;
}}
Expand All @@ -345,7 +346,7 @@ class Config extends Component {
value={jsonData}
handleChange={this.onJsonDataChange}
handleSave={this.setJsonData}
maxLength="3072"
maxLength={MAX_TEXT_LEN}
buttons={[
<Button key="save" type="primary" onClick={this.setJsonData} disabled={jsonDataDisabled}><Icon type="save" />保存</Button>]
}
Expand Down
2 changes: 1 addition & 1 deletion src/capture/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,7 @@ class Capture extends Component {
>
<Input
className="n-test-url"
maxLength={512}
maxLength={1024}
value={testUrl}
placeholder="请输入页面的URL"
onChange={this.onTestUrlChange}
Expand Down

0 comments on commit 44ada1f

Please sign in to comment.