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:
parent
d717a46c6e
commit
d392cda3d4
@ -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,
|
||||
|
@ -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 &&
|
||||
(
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user