Skip to content

Title duplication bug with non-alphabetic characters (Korean, Japanese, Numbers) #2465

@hsp1020

Description

@hsp1020

Steps to reproduce

this bug affects not only Korean but also Japanese, numbers, and other non-alphabetic characters where isLowerCase() returns false.

Examples:

Korean: 아기가 → 아기가기가
Japanese: ミッキー → ミッキーッキー
Numbers: 1923 → 1923923

Expected behavior

cloudstream/library/src/commonMain/kotlin/com/lagradost/cloudstream3/MainAPI.kt

fun fixTitle(str: String): String {
return str.split(" ").joinToString(" ") {
it.lowercase().replaceFirstChar { char ->
if (char.isLowerCase())
char.titlecase(Locale.getDefault())
else
char.toString() // [FIX] 'it' (word) -> 'char.toString()' (character)
}
}
}

Actual behavior

cloudstream/library/src/commonMain/kotlin/com/lagradost/cloudstream3/MainAPI.kt

fun fixTitle(str: String): String {
return str.split(" ").joinToString(" ") {
// Here, 'it' refers to the entire split word. (e.g., "아기가")
it.lowercase().replaceFirstChar { char ->
// Here, 'char' is the first character ('아').
if (char.isLowerCase())
char.titlecase(Locale.getDefault())
else
it // <--- Critical mistake!
// Here, 'it' refers to the entire word from the outer scope ("아기가"), not the first character.
}
}

Cloudstream version and commit hash

4.6.2-PRE 06456bc

Android version

Android 14

Logcat

Other details

Consequently, when the first character is not a lowercase letter (e.g., Korean, Kanji, or Numbers), the code replaces the first character with the entire word.
Example logic: Replacing '아' (first char) with '아기가' (entire word) results in '아기가' + '기가' = '아기가기가'.

Since I'm on mobile, I can't submit a PR, so I'm posting it as an issue.

Acknowledgements

  • I am sure my issue is related to the app and NOT some extension.
  • I have searched the existing issues and this is a new ticket, NOT a duplicate or related to another open issue.
  • I have written a short but informative title.
  • I have updated the app to pre-release version Latest.
  • I will fill out all of the requested information in this form.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions