Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AppleDict-bin: fix crash for multidirectional dicts #480

Merged
merged 1 commit into from
Jun 10, 2023

Conversation

soshial
Copy link
Contributor

@soshial soshial commented Jun 10, 2023

DCSPrivateFlag may be bigger than 0x20. Fixed that.

DCSDictionaryLanguages array inside plist file has a list of dictionaries inside this file
This DCSPrivateFlag per each article provides not only priority and parental control, but also a flag of translation direction:

  • 0x0-0x1f values are reserved for the first language from the DCSDictionaryLanguages array
  • 0x20-0x3f values are reserved for the second language etc.

# d:parental-control="1"
parentalControl = priorityAndParentalControl % 2
# d:priority=".." between 0x00..0x12, priority = [0..9]
priority = (priorityAndParentalControl - parentalControl) // 2
else:
priority = 0
parentalControl = 0
log.error('Unknown private field: ' + properties.key_text_fixed_fields)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use f-string.

@ilius
Copy link
Owner

ilius commented Jun 10, 2023

Can we move all this if-elses to a method of properties that return priority and parentalControl?

@soshial soshial force-pushed the appledict-multidirectional-fix branch from 6618856 to 928f348 Compare June 10, 2023 16:58
@soshial
Copy link
Contributor Author

soshial commented Jun 10, 2023

Well, in readKeyTextData() we list through a single file and extract one value straight after another. If it's all in one method, we can see the exact order. If the logic is in several methods, then those methods might change order by mistake...

extractLexeme()
extractFlags()
extractForms()

I don't know.

@ilius ilius merged commit 4e935f3 into ilius:master Jun 10, 2023
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants