Skip to content

Commit

Permalink
UserDef // +filterNonCNSReadingsForCHTInput.
Browse files Browse the repository at this point in the history
  • Loading branch information
ShikiSuen committed Feb 15, 2024
1 parent f0be5ed commit 68a9137
Show file tree
Hide file tree
Showing 10 changed files with 71 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ public class LMMgr {
config.isSymbolEnabled = PrefMgr.shared.symbolInputEnabled
config.isSCPCEnabled = PrefMgr.shared.useSCPCTypingMode
config.isCassetteEnabled = PrefMgr.shared.cassetteEnabled
config.filterNonCNSReadings = PrefMgr.shared.filterNonCNSReadingsForCHTInput
config.deltaOfCalendarYears = PrefMgr.shared.deltaOfCalendarYears
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,9 @@ import SwiftExtension
@AppProperty(key: UserDef.kInlineDumpPinyinInLieuOfZhuyin.rawValue, defaultValue: false)
public dynamic var inlineDumpPinyinInLieuOfZhuyin: Bool

@AppProperty(key: UserDef.kFilterNonCNSReadingsForCHTInput.rawValue, defaultValue: false)
public dynamic var filterNonCNSReadingsForCHTInput: Bool

@AppProperty(key: UserDef.kCNS11643Enabled.rawValue, defaultValue: false)
public dynamic var cns11643Enabled: Bool {
didSet {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,40 +44,54 @@ public extension SettingsPanesCocoa {
"Due to security concerns, we don't consider implementing anything related to shell script execution here. An input method doing this without implementing App Sandbox will definitely have system-wide vulnerabilities, considering that its related UserDefaults are easily tamperable to execute malicious shell scripts. vChewing is designed to be invulnerable from this kind of attack. Also, official releases of vChewing are Sandboxed.".makeNSLabel(descriptive: true, fixWidth: contentWidth)
}
}?.boxed()
NSStackView.buildSection(width: contentWidth) {
UserDef.kUseExternalFactoryDict.render(fixWidth: contentWidth) { renderable in
renderable.currentControl?.target = self
renderable.currentControl?.action = #selector(self.lmmgrConnectCoreDB(_:))
}
UserDef.kFetchSuggestionsFromUserOverrideModel.render(fixWidth: contentWidth)
UserDef.kCNS11643Enabled.render(fixWidth: contentWidth) { renderable in
renderable.currentControl?.target = self
renderable.currentControl?.action = #selector(self.lmmgrSyncLMPrefs(_:))
}
UserDef.kSymbolInputEnabled.render(fixWidth: contentWidth) { renderable in
renderable.currentControl?.target = self
renderable.currentControl?.action = #selector(self.lmmgrSyncLMPrefs(_:))
}
UserDef.kPhraseReplacementEnabled.render(fixWidth: contentWidth) { renderable in
renderable.currentControl?.target = self
renderable.currentControl?.action = #selector(self.lmmgrSyncLMPrefsWithReplacementTable(_:))
NSTabView.build {
NSTabView.TabPage(title: "") {
NSStackView.buildSection(width: innerContentWidth) {
UserDef.kFetchSuggestionsFromUserOverrideModel.render(fixWidth: innerContentWidth)
UserDef.kFilterNonCNSReadingsForCHTInput.render(fixWidth: innerContentWidth) { renderable in
renderable.currentControl?.target = self
renderable.currentControl?.action = #selector(self.lmmgrSyncLMPrefs(_:))
}
UserDef.kCNS11643Enabled.render(fixWidth: innerContentWidth) { renderable in
renderable.currentControl?.target = self
renderable.currentControl?.action = #selector(self.lmmgrSyncLMPrefs(_:))
}
UserDef.kSymbolInputEnabled.render(fixWidth: innerContentWidth) { renderable in
renderable.currentControl?.target = self
renderable.currentControl?.action = #selector(self.lmmgrSyncLMPrefs(_:))
}
}?.boxed()
NSView()
}
}?.boxed()
NSStackView.buildSection(width: contentWidth) {
UserDef.kAllowBoostingSingleKanjiAsUserPhrase.render(fixWidth: contentWidth)
NSStackView.build(.horizontal) {
"i18n:settings.importFromKimoTxt.label".makeNSLabel(fixWidth: contentWidth)
NSTabView.TabPage(title: "") {
NSStackView.buildSection(width: innerContentWidth) {
UserDef.kUseExternalFactoryDict.render(fixWidth: innerContentWidth) { renderable in
renderable.currentControl?.target = self
renderable.currentControl?.action = #selector(self.lmmgrConnectCoreDB(_:))
}
UserDef.kPhraseReplacementEnabled.render(fixWidth: innerContentWidth) { renderable in
renderable.currentControl?.target = self
renderable.currentControl?.action = #selector(self.lmmgrSyncLMPrefsWithReplacementTable(_:))
}
UserDef.kAllowBoostingSingleKanjiAsUserPhrase.render(fixWidth: innerContentWidth)
}?.boxed()
NSView()
NSStackView.build(.horizontal, spacing: 4) {
importKimoDragButton()
NSButton(
"i18n:settings.importFromKimoTxt.DirectlyImport",
target: self,
action: #selector(importYahooKeyKeyUserDictionaryDataXPC(_:))
)
}
}
}?.boxed()
NSStackView.buildSection(width: contentWidth) {
NSStackView.build(.horizontal) {
"i18n:settings.importFromKimoTxt.label".makeNSLabel(fixWidth: contentWidth)
NSView()
NSStackView.build(.horizontal, spacing: 4) {
importKimoDragButton()
NSButton(
"i18n:settings.importFromKimoTxt.DirectlyImport",
target: self,
action: #selector(importYahooKeyKeyUserDictionaryDataXPC(_:))
)
}
}
}?.boxed()
}?.makeSimpleConstraint(.width, relation: .equal, value: tabContainerWidth)
NSView().makeSimpleConstraint(.height, relation: .equal, value: NSFont.systemFontSize)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ public struct VwrSettingsPaneDictionary: View {
@AppStorage(wrappedValue: false, UserDef.kAllowBoostingSingleKanjiAsUserPhrase.rawValue)
private var allowBoostingSingleKanjiAsUserPhrase: Bool

@AppStorage(wrappedValue: false, UserDef.kFilterNonCNSReadingsForCHTInput.rawValue)
private var filterNonCNSReadingsForCHTInput: Bool

// MARK: - Main View

@State var keykeyImportButtonDisabled = false
Expand Down Expand Up @@ -164,6 +167,11 @@ public struct VwrSettingsPaneDictionary: View {
LMMgr.connectCoreDB()
}
).render()
UserDef.kFilterNonCNSReadingsForCHTInput.bind(
$filterNonCNSReadingsForCHTInput.didChange {
LMMgr.connectCoreDB()
}
).render()
UserDef.kCNS11643Enabled.bind(
$cns11643Enabled.didChange {
LMMgr.syncLMPrefs()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ public protocol PrefMgrProtocol {
var shareAlphanumericalModeStatusAcrossClients: Bool { get set }
var phraseEditorAutoReloadExternalModifications: Bool { get set }
var classicHaninKeyboardSymbolModeShortcutEnabled: Bool { get set }
var filterNonCNSReadingsForCHTInput: Bool { get set }
var cns11643Enabled: Bool { get set }
var cassetteEnabled: Bool { get set }
var symbolInputEnabled: Bool { get set }
Expand Down
5 changes: 5 additions & 0 deletions Packages/vChewing_Shared/Sources/Shared/UserDef/UserDef.swift
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ public enum UserDef: String, CaseIterable, Identifiable {
case kShareAlphanumericalModeStatusAcrossClients = "ShareAlphanumericalModeStatusAcrossClients"
case kPhraseEditorAutoReloadExternalModifications = "PhraseEditorAutoReloadExternalModifications"
case kClassicHaninKeyboardSymbolModeShortcutEnabled = "ClassicHaninKeyboardSymbolModeShortcutEnabled"
case kFilterNonCNSReadingsForCHTInput = "FilterNonCNSReadingsForCHTInput"

case kUseSpaceToCommitHighlightedSCPCCandidate = "UseSpaceToCommitHighlightedSCPCCandidate"
case kEnableMouseScrollingForTDKCandidatesCocoa = "EnableMouseScrollingForTDKCandidatesCocoa"
Expand Down Expand Up @@ -225,6 +226,7 @@ public extension UserDef {
case .kShareAlphanumericalModeStatusAcrossClients: return .bool
case .kPhraseEditorAutoReloadExternalModifications: return .bool
case .kClassicHaninKeyboardSymbolModeShortcutEnabled: return .bool
case .kFilterNonCNSReadingsForCHTInput: return .bool
case .kUseSpaceToCommitHighlightedSCPCCandidate: return .bool
case .kEnableMouseScrollingForTDKCandidatesCocoa: return .bool
case .kDisableSegmentedThickUnderlineInMarkingModeForManagedClients: return .bool
Expand Down Expand Up @@ -545,6 +547,9 @@ public extension UserDef {
case .kClassicHaninKeyboardSymbolModeShortcutEnabled: return .init(
userDef: self, shortTitle: "Also use “\\” or “¥” key for Hanin Keyboard Symbol Input"
)
case .kFilterNonCNSReadingsForCHTInput: return .init(
userDef: self, shortTitle: "i18n:UserDef.kFilterNonCNSReadingsForCHTInput.shortTitle"
)
case .kUseSpaceToCommitHighlightedSCPCCandidate: return .init(
userDef: self, shortTitle: "Use Space to confirm highlighted candidate in Per-Char Select Mode"
)
Expand Down
3 changes: 2 additions & 1 deletion Source/Resources/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -201,16 +201,17 @@
"i18n:securityAgentHelper.warningMessage.footer" = "When this message shows up, vChewing has already attempted to call DisableSecureEventInput() trying to make itself selectable in the input method menu again. Your suggested further steps:\n\n0. Keep a screenshot of this dialog (if you don't have one) for further purposes.\n\n1. If vChewing is still not selectable in the input method menu, you are suggested to manually terminate the processes listed above to force-release their SecureEventInput states. This will make vChewing available immediately.\n\n2. If the process belongs to an app from Mac App Store, please report its abuse of SecureEventInput to Apple. Apple may take actions to such apps if necessary, including pulling them off from the Mac App Store until the problem gets solved by the developers of such apps.\n\n3. Whether this process is from Mac App Store or not, you report this abuse to the related app vendor / developer. You may give them the screenshot of this alert message since it should have enough information to help the vendor / developer troubleshoot the issue.";
"i18n:securityAgentHelper.warningMessage.header" = "vChewing has detected that the following background processes are abusing the SecureEventInput, hindering all 3rd-party input methods from being able to switch to.\n\nIt is fine to use SecureEventInput for sensitive input fields. However, an app calling EnableSecureEventInput() is responsible to call DisableSecureEventInput() immediately right after the input field loses focus. This situation may also happen if an app is hanging in the background (or working as a helper application in the background) with its SecureEventInput left enabled.\n\nThe found processes are:";
"i18n:securityAgentHelper.warningMessage.title" = "SecureEventInput Abuse Detected";
"i18n:settings.importFromKimoTxt.label" = "Import Yahoo! KeyKey User Dictionary file";
"i18n:settings.importFromKimoTxt.DirectlyImport" = "Directly Import";
"i18n:settings.importFromKimoTxt.finishedCount:%@" = "Imported %@ new records.";
"i18n:settings.importFromKimoTxt.label" = "Import Yahoo! KeyKey User Dictionary file";
"i18n:settings.shiftKeyASCIITogle.description" = "This feature only needs to parse consecutive NSEvents passed by macOS built-in InputMethodKit framework, hence no necessity of asking end-users for extra privileges of monitoring global keyboard inputs. You are free to investigate our codebase or reverse-engineer this input method to see whether the above statement is trustable. Also, this Shift-key toggle won't work if CapsLock is ON.";
"i18n:UserDef.kBypassNonAppleCapsLockHandling.description" = "This won't affect the same feature offered by macOS since 10.14 Mojave and later.";
"i18n:UserDef.kBypassNonAppleCapsLockHandling.shortTitle" = "Bypass the vChewing built-in Caps Lock handling";
"i18n:userdef.kCheckAbusersOfSecureEventInputAPI.description" = "Such abuse of SecureEventInput API in the background can hinder all 3rd-party input methods from being able to switch to. It is fine to use SecureEventInput for sensitive input fields. However, an app calling EnableSecureEventInput() is responsible to call DisableSecureEventInput() immediately right after the input field loses focus. This situation may also happen if an app is hanging in the background (or working as a helper application in the background) with its SecureEventInput left enabled.";
"i18n:UserDef.kCheckAbusersOfSecureEventInputAPI.shortTitle" = "Actively check those processes abusing the SecureEventInput API";
"i18n:UserDef.kCNS11643Enabled.shortTitle" = "Enable CNS11643 Support (2024-01-23)";
"i18n:UserDef.kDodgeInvalidEdgeCandidateCursorPosition.shortTitle" = "Dodge Invalid Edge Candidate Cursor Position";
"i18n:UserDef.kFilterNonCNSReadingsForCHTInput.shortTitle" = "Filter Non-CNS11643 factory readings (CHT input only)";
"i18n:UserDef.kNumPadCharInputBehavior.description" = "Choose the behavior of numeric pad inputs.";
"i18n:UserDef.kNumPadCharInputBehavior.option.0" = "Always directly commit half-width chars";
"i18n:UserDef.kNumPadCharInputBehavior.option.1" = "Always directly commit full-width chars";
Expand Down
3 changes: 2 additions & 1 deletion Source/Resources/ja.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -201,16 +201,17 @@
"i18n:securityAgentHelper.warningMessage.footer" = "このメッセージが出た時に、威注音がすでに「DisableSecureEventInput()」を実行してみました。これで入力ソースメニューで威注音は利用できる状態になったかもしれませんが、下記のステップはおすすめです:\n\nイ)今のこのメッセージの画面のスクリーンショットを撮って置いてください。後ほど使えます。\n\nロ)もし、今でも入力ソースメニューで威注音は利用できぬ状態でしたら、上記のプロセスを(強制)中止してください。そうすれば、それぞれのSecureEventInput状態は解消できて、入力ソースメニューで威注音はすぐ利用できることになります。\n\nハ)もし、該当プロセスは Mac App Store のアプリからのものでしたら、該当アプリを Apple 社にご通報ください。状況と必要性次第、該当アプリは Mac App Store からしばらく取り下がて、支障解決まで Mac App Store 提供中止になるかもしれません。\n\nニ)該当プロセスは Mac App Store からダウンロードしたものか否か、それぞれの開発元にこの支障をご通報ください。今のこのメッセージの画面のスクリーンショットを該当開発元に送れば、必要なる情報は該当開発元に全部お知らせすることができます。";
"i18n:securityAgentHelper.warningMessage.header" = "威注音入力アプリ(略称「威注音」)は「他のバックグラウンド・プロセスがSecureEventInputを正しく利用していない」と検出しました。このような不正利用は「システム内蔵入力以外の全ての入力アプリがメニューで灰色状態で選べなくて使えない」の元凶です。\n\nセンシティブな資料の記入どころでSecureEventInputをEnableSecureEventInput()で使うのは当然ですが、「入力中」状態が終わった後必ずDisableSecureEventInput()で状態解消すべきだと義務です。いくつかヘルパーアプリも、あるいはSecureEventInputを呼び起こしてからすぐ固まったアプリも、この状態になりやすいです。特に、他のアプリの画面へ切り替えたとしても、固まったアプリのSecureEventInput状態は自動的に解消できません。\n\n検出した該当プロセスは:";
"i18n:securityAgentHelper.warningMessage.title" = "SecureEventInput の不正利用が検出";
"i18n:settings.importFromKimoTxt.label" = "Yahoo! KeyKey ユーザー辞書ファイルを読込";
"i18n:settings.importFromKimoTxt.DirectlyImport" = "直接読込";
"i18n:settings.importFromKimoTxt.finishedCount:%@" = "新しい記録は %@ つ読み込みました。";
"i18n:settings.importFromKimoTxt.label" = "Yahoo! KeyKey ユーザー辞書ファイルを読込";
"i18n:settings.shiftKeyASCIITogle.description" = "この機能の利用する NSEvent は、macOS 内蔵の入力アプリ共用モジュール「InputMethodKit」から提供した NSEvent のみであり、その NSEvent 文脈関係で「Shift キーは1回押したかどうか」と判断することはできる。この事実に疑いを持つ者は、本アプリのソースコードを審査するか、あるいは本アプリを逆向工程(分解工学, いわゆる「Reverse-Engineering」)するがよい。なお、Shiftキーによるこの切り替えは、CapsLockがONの時には効かぬ。";
"i18n:UserDef.kBypassNonAppleCapsLockHandling.description" = "macOS 10.14 からのシステム内蔵機能としての同じ機能に影響しません。";
"i18n:UserDef.kBypassNonAppleCapsLockHandling.shortTitle" = "威注音入力アプリの内蔵CapsLock処理を不使用";
"i18n:userdef.kCheckAbusersOfSecureEventInputAPI.description" = "このような不正利用は「システム内蔵入力以外の全ての入力アプリがメニューで灰色状態で選べなくて使えない」の元凶である。センシティブな資料の記入どころでSecureEventInputをEnableSecureEventInput()で使うのは当然であるが、「入力中」状態が終わった後必ずDisableSecureEventInput()で状態解消すべきだと義務である。いくつかヘルパーアプリも、あるいはSecureEventInputを呼び起こしてからすぐ固まったアプリも、この状態になりやすい。特に、他のアプリの画面へ切り替えたとしても、固まったアプリのSecureEventInput状態は自動的に解消できぬ。";
"i18n:UserDef.kCheckAbusersOfSecureEventInputAPI.shortTitle" = "SecureEventInput API を不正利用しているバクグラウンド・プロセスを自動検知";
"i18n:UserDef.kCNS11643Enabled.shortTitle" = "全字庫モード // 入力可能な漢字数を倍増す (2024-01-23)";
"i18n:UserDef.kDodgeInvalidEdgeCandidateCursorPosition.shortTitle" = "端末での不合理的な候補選択用カーソル位置を是正";
"i18n:UserDef.kFilterNonCNSReadingsForCHTInput.shortTitle" = "全字庫以外の音読みを内蔵辞書繁体中国語検索結果から除く";
"i18n:UserDef.kNumPadCharInputBehavior.description" = "テンキー文字の入力行為をご指定ください。";
"i18n:UserDef.kNumPadCharInputBehavior.option.0" = "いつでも半角で直接出力";
"i18n:UserDef.kNumPadCharInputBehavior.option.1" = "いつでも全角で直接出力";
Expand Down
Loading

0 comments on commit 68a9137

Please sign in to comment.