diff options
4 files changed, 45 insertions, 13 deletions
diff --git a/lint/libs/lint_checks/src/com/android/tools/lint/checks/ManifestOrderDetector.java b/lint/libs/lint_checks/src/com/android/tools/lint/checks/ManifestOrderDetector.java index bc5084f..71b5191 100644 --- a/lint/libs/lint_checks/src/com/android/tools/lint/checks/ManifestOrderDetector.java +++ b/lint/libs/lint_checks/src/com/android/tools/lint/checks/ManifestOrderDetector.java @@ -85,7 +85,7 @@ public class ManifestOrderDetector extends Detector implements Detector.XmlScann "Checks that the minimum SDK and target SDK attributes are defined", "The manifest should contain a `<uses-sdk>` element which defines the " + - "minimum minimum API Level required for the application to run, " + + "minimum API Level required for the application to run, " + "as well as the target version (the highest API level you have tested " + "the version for.)", diff --git a/lint/libs/lint_checks/src/com/android/tools/lint/checks/TypoDetector.java b/lint/libs/lint_checks/src/com/android/tools/lint/checks/TypoDetector.java index 6f85505..7a38d97 100644 --- a/lint/libs/lint_checks/src/com/android/tools/lint/checks/TypoDetector.java +++ b/lint/libs/lint_checks/src/com/android/tools/lint/checks/TypoDetector.java @@ -16,8 +16,8 @@ package com.android.tools.lint.checks; -import static com.android.tools.lint.checks.TypoLookup.isLetter; import static com.android.SdkConstants.TAG_STRING; +import static com.android.tools.lint.checks.TypoLookup.isLetter; import static com.google.common.base.Objects.equal; import com.android.annotations.NonNull; @@ -183,15 +183,27 @@ public class TypoDetector extends ResourceXmlDetector { int index = 0; boolean checkedTypos = false; while (index < max) { - while (index < max && !Character.isLetter(text.charAt(index))) { - index++; + for (; index < max; index++) { + char c = text.charAt(index); + if (c == '\\') { + index++; + continue; + } else if (Character.isLetter(c)) { + break; + } } - if (index == max) { + if (index >= max) { return; } int begin = index; - while (index < max && Character.isLetter(text.charAt(index))) { - if (text.charAt(index) >= 0x80) { + for (; index < max; index++) { + char c = text.charAt(index); + if (c == '\\') { + index++; + break; + } else if (!Character.isLetter(c)) { + break; + } else if (text.charAt(index) >= 0x80) { // Switch to UTF-8 handling for this string if (checkedTypos) { // If we've already checked words we may have reported typos @@ -207,7 +219,6 @@ public class TypoDetector extends ResourceXmlDetector { } return; } - index++; } int end = index; @@ -228,7 +239,13 @@ public class TypoDetector extends ResourceXmlDetector { // Find beginning of word while (index < byteEnd) { byte b = utf8Text[index]; - if (isLetter(b)) { + if (b == '\\') { + index++; + charStart++; + if (index < byteEnd) { + b = utf8Text[index]; + } + } else if (isLetter(b)) { break; } index++; @@ -238,7 +255,7 @@ public class TypoDetector extends ResourceXmlDetector { } } - if (index == byteEnd) { + if (index >= byteEnd) { return; } int charEnd = charStart; @@ -248,7 +265,17 @@ public class TypoDetector extends ResourceXmlDetector { // bytes won't match these ASCII characters (because the high bit must be set there) while (index < byteEnd) { byte b = utf8Text[index]; - if (!isLetter(b)) { + if (b == '\\') { + index++; + charEnd++; + if (index < byteEnd) { + b = utf8Text[index++]; + if ((b & 0x80) == 0 || (b & 0xC0) == 0xC0) { + charEnd++; + } + } + break; + } else if (!isLetter(b)) { break; } index++; diff --git a/lint/libs/lint_checks/tests/src/com/android/tools/lint/checks/data/res/values-de/typos.xml b/lint/libs/lint_checks/tests/src/com/android/tools/lint/checks/data/res/values-de/typos.xml index 9583fc7..5108cc9 100644 --- a/lint/libs/lint_checks/tests/src/com/android/tools/lint/checks/data/res/values-de/typos.xml +++ b/lint/libs/lint_checks/tests/src/com/android/tools/lint/checks/data/res/values-de/typos.xml @@ -8,5 +8,7 @@ </string> <string name="s2">(Authorisierungscode!)</string> <string name="s3"> zurück gefoobaren!</string> + <!-- escaped separator --> + <string name="issue39599">"ü test\nciht zu"</string> </resources> diff --git a/lint/libs/lint_checks/tests/src/com/android/tools/lint/checks/data/res/values/typos.xml b/lint/libs/lint_checks/tests/src/com/android/tools/lint/checks/data/res/values/typos.xml index a94be49..dd24812 100644 --- a/lint/libs/lint_checks/tests/src/com/android/tools/lint/checks/data/res/values/typos.xml +++ b/lint/libs/lint_checks/tests/src/com/android/tools/lint/checks/data/res/values/typos.xml @@ -18,5 +18,8 @@ <string name="s8">OK Cancel dialog with a long message</string> <!-- case changes only: invalid --> <string name="dlg_button_ok">Ok</string> -</resources> - + <!-- escaped separator --> + <string name="issue39599">"Please take a moment\nto rate ^1"</string> + <!-- escaped separator 2 --> + <string name="issue39599_2">"\nto</string> +</resources>
\ No newline at end of file |