mirror of https://github.com/FreeTubeApp/FreeTube
Fix block channel channel ID validation (#4366)
This commit is contained in:
parent
3fc2e547c9
commit
c219926c5e
|
@ -5,7 +5,7 @@ import FtToggleSwitch from '../ft-toggle-switch/ft-toggle-switch.vue'
|
|||
import FtInputTags from '../../components/ft-input-tags/ft-input-tags.vue'
|
||||
import FtFlexBox from '../ft-flex-box/ft-flex-box.vue'
|
||||
import { showToast } from '../../helpers/utils'
|
||||
import { checkYoutubeId, findChannelTagInfo } from '../../helpers/channels'
|
||||
import { checkYoutubeChannelId, findChannelTagInfo } from '../../helpers/channels'
|
||||
|
||||
export default defineComponent({
|
||||
name: 'PlayerSettings',
|
||||
|
@ -152,7 +152,7 @@ export default defineComponent({
|
|||
showToast(this.$t('Settings.Distraction Free Settings.Hide Channels Already Exists'))
|
||||
},
|
||||
validateChannelId: function (text) {
|
||||
return checkYoutubeId(text)
|
||||
return checkYoutubeChannelId(text)
|
||||
},
|
||||
findChannelTagInfo: async function (text) {
|
||||
return await findChannelTagInfo(text, this.backendOptions)
|
||||
|
@ -167,7 +167,7 @@ export default defineComponent({
|
|||
if (tag.invalid) continue
|
||||
|
||||
// process if no preferred name and is possibly a YouTube ID
|
||||
if (tag.preferredName === '' && checkYoutubeId(tag.name)) {
|
||||
if (tag.preferredName === '' && checkYoutubeChannelId(tag.name)) {
|
||||
this.channelHiderDisabled = true
|
||||
|
||||
const { preferredName, icon, iconHref, invalidId } = await this.findChannelTagInfo(tag.name)
|
||||
|
|
|
@ -43,7 +43,7 @@ async function findChannelById(id, backendOptions) {
|
|||
* @returns {Promise<{icon: string, iconHref: string, preferredName: string} | { invalidId: boolean }>}
|
||||
*/
|
||||
export async function findChannelTagInfo(id, backendOptions) {
|
||||
if (!/UC\S{22}/.test(id)) return { invalidId: true }
|
||||
if (!checkYoutubeChannelId(id)) return { invalidId: true }
|
||||
try {
|
||||
const channel = await findChannelById(id, backendOptions)
|
||||
if (!process.env.IS_ELECTRON || backendOptions.preference === 'invidious') {
|
||||
|
@ -71,6 +71,6 @@ export async function findChannelTagInfo(id, backendOptions) {
|
|||
* @param {string} id
|
||||
* @returns {boolean}
|
||||
*/
|
||||
export function checkYoutubeId(id) {
|
||||
return /UC\S{22}/.test(id)
|
||||
export function checkYoutubeChannelId(id) {
|
||||
return /^UC[\w-]{22}$/.test(id)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue