0
0
mirror of https://github.com/ankidroid/Anki-Android.git synced 2024-09-20 03:52:15 +02:00

fix: Lint handling of CDATA elements

lint 30.2.0 auto-converts XML text nodes to CDATA

This uncovered a few bugs in our lint checks where we did not check
CDATA nodes

Unblocks 11298
This commit is contained in:
David Allison 2022-05-10 16:23:33 +01:00 committed by Mike Hardy
parent d717a46c6e
commit d392cda3d4
3 changed files with 3 additions and 3 deletions

View File

@ -79,7 +79,7 @@ class DuplicateCrowdInStrings : ResourceXmlDetector() {
if (childNodes.length > 0) {
if (childNodes.length == 1) {
val child = childNodes.item(0)
if (child.nodeType == Node.TEXT_NODE) {
if (child.nodeType == Node.TEXT_NODE || child.nodeType == Node.CDATA_SECTION_NODE) {
checkTextNode(
context,
element,

View File

@ -68,7 +68,7 @@ class InvalidStringFormatDetector : ResourceXmlDetector() {
element.childNodes
.forEach { child ->
val isStringResource = child.nodeType == Node.TEXT_NODE &&
val isStringResource = (child.nodeType == Node.TEXT_NODE || child.nodeType == Node.CDATA_SECTION_NODE) &&
TAG_STRING == element.localName
val isStringArrayOrPlurals = child.nodeType == Node.ELEMENT_NODE &&
(

View File

@ -109,7 +109,7 @@ class NonPositionalFormatSubstitutions : ResourceXmlDetector() {
if (childNodes.length == 1) {
val child = childNodes.item(0)
return if (child.nodeType != Node.TEXT_NODE) {
return if (child.nodeType != Node.TEXT_NODE && child.nodeType != Node.CDATA_SECTION_NODE) {
null
} else {
StringFormatDetector.stripQuotes(child.nodeValue)