From 563294b36e6e038278e18b6dc764b2c9d8283b65 Mon Sep 17 00:00:00 2001 From: Sean Owen Date: Fri, 30 Jan 2015 17:08:37 +0000 Subject: [PATCH 1/9] Fix unescaped quote in new translation and make translator escape quotes going forward --- android/res/values-fr/strings.xml | 2 +- .../com/google/zxing/StringsResourceTranslator.java | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/android/res/values-fr/strings.xml b/android/res/values-fr/strings.xml index 4d524a5b7..43f92072a 100644 --- a/android/res/values-fr/strings.xml +++ b/android/res/values-fr/strings.xml @@ -112,7 +112,7 @@ Améliore le balayage lors d\'une faible luminosité sur certains téléphone, mais peut causer un reflet. Ne fonctionne pas sur tous les téléphones. Utiliser la lumière frontale Paramètres généraux - Stockez vos scans dans l'histoire + Stockez vos scans dans l\'histoire Ajouter à Histoire Balayer des codes-barres blancs sur fond noir. Non disponible sur certains appareils. Balayage négatif diff --git a/javase/src/main/java/com/google/zxing/StringsResourceTranslator.java b/javase/src/main/java/com/google/zxing/StringsResourceTranslator.java index e08ba227d..91ae520f3 100644 --- a/javase/src/main/java/com/google/zxing/StringsResourceTranslator.java +++ b/javase/src/main/java/com/google/zxing/StringsResourceTranslator.java @@ -118,7 +118,9 @@ public final class StringsResourceTranslator { String parentName = translatedFile.getParent().getFileName().toString(); Matcher stringsFileNameMatcher = STRINGS_FILE_NAME_PATTERN.matcher(parentName); - stringsFileNameMatcher.find(); + if (!stringsFileNameMatcher.find()) { + throw new IllegalArgumentException("Invalid parent dir: " + parentName); + } String language = stringsFileNameMatcher.group(1); String massagedLanguage = LANGUAGE_CODE_MASSAGINGS.get(language); if (massagedLanguage != null) { @@ -151,6 +153,8 @@ public final class StringsResourceTranslator { if (translatedString == null || forceRetranslation.contains(key)) { anyChange = true; translatedString = translateString(value, language); + // Specially for string resources, escape ' with \ + translatedString = translatedString.replaceAll("'", "\\\\'"); } out.write(translatedString); @@ -193,10 +197,8 @@ public final class StringsResourceTranslator { String translation = m.group(1); // This is a little crude; unescape some common escapes in the raw response - translation = translation.replaceAll(""", "\""); - translation = translation.replaceAll("'", "'"); - translation = translation.replaceAll("&quot;", "\""); - translation = translation.replaceAll("&#39;", "'"); + translation = translation.replaceAll("&(amp;)?quot;", "\""); + translation = translation.replaceAll("&(amp;)?#39;", "'"); System.out.println(" Got translation " + translation); return translation; From 3ef50066db546100bc16c9e6f1f2e681f5dc6ae9 Mon Sep 17 00:00:00 2001 From: Sean Owen Date: Fri, 30 Jan 2015 17:11:07 +0000 Subject: [PATCH 2/9] Remove explicit Central ref; move jarsigner config to pluginManagement --- pom.xml | 63 ++++++++++++++++++++------------------------------------- 1 file changed, 22 insertions(+), 41 deletions(-) diff --git a/pom.xml b/pom.xml index f4af341b8..f9819c0a6 100644 --- a/pom.xml +++ b/pom.xml @@ -99,25 +99,6 @@ 3.1.1-SNAPSHOT - - - central - https://repo1.maven.org/maven2 - - true - - - - - - central - https://repo1.maven.org/maven2 - - true - - - - @@ -253,6 +234,28 @@ org.apache.maven.plugins maven-jarsigner-plugin 1.3.2 + + + signing + + sign + + package + + + target/*.apk + + ../private/ZXing.keystore + zxing + + -sigalg + MD5withRSA + -digestalg + SHA1 + + + + org.apache.maven.plugins @@ -620,28 +623,6 @@ org.apache.maven.plugins maven-jarsigner-plugin - - - signing - - sign - - package - - - target/*.apk - - ../private/ZXing.keystore - zxing - - -sigalg - MD5withRSA - -digestalg - SHA1 - - - - com.jayway.maven.plugins.android.generation2 From c02bf4ca8eb81c1de2f4de3d401603d509877c89 Mon Sep 17 00:00:00 2001 From: Sean Owen Date: Fri, 30 Jan 2015 18:18:32 +0000 Subject: [PATCH 3/9] Fix javadoc 8 error --- .../zxing/client/android/camera/open/OpenCameraInterface.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/android/src/com/google/zxing/client/android/camera/open/OpenCameraInterface.java b/android/src/com/google/zxing/client/android/camera/open/OpenCameraInterface.java index b383300cc..1f53bdbc2 100644 --- a/android/src/com/google/zxing/client/android/camera/open/OpenCameraInterface.java +++ b/android/src/com/google/zxing/client/android/camera/open/OpenCameraInterface.java @@ -26,7 +26,7 @@ public final class OpenCameraInterface { private OpenCameraInterface() { } - /** For {@link #open(int), means no preference for which camera to open. */ + /** For {@link #open(int)}, means no preference for which camera to open. */ public static final int NO_REQUESTED_CAMERA = -1; /** From 894ab95ea04b46abcb8c568c1bb8295d555ce2fc Mon Sep 17 00:00:00 2001 From: Sean Owen Date: Fri, 30 Jan 2015 20:35:37 +0000 Subject: [PATCH 4/9] Closes issue #302 : incorrectly remembers state from Intent after processing --- .../src/com/google/zxing/client/android/CaptureActivity.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/android/src/com/google/zxing/client/android/CaptureActivity.java b/android/src/com/google/zxing/client/android/CaptureActivity.java index d4fe7dbc6..09e735c91 100755 --- a/android/src/com/google/zxing/client/android/CaptureActivity.java +++ b/android/src/com/google/zxing/client/android/CaptureActivity.java @@ -198,6 +198,8 @@ public final class CaptureActivity extends Activity implements SurfaceHolder.Cal && (intent == null || intent.getBooleanExtra(Intents.Scan.SAVE_HISTORY, true)); source = IntentSource.NONE; + sourceUrl = null; + scanFromWebPageManager = null; decodeFormats = null; characterSet = null; @@ -681,6 +683,7 @@ public final class CaptureActivity extends Activity implements SurfaceHolder.Cal if (scanFromWebPageManager != null && scanFromWebPageManager.isScanFromWebPage()) { String replyURL = scanFromWebPageManager.buildReplyURL(rawResult, resultHandler); + scanFromWebPageManager = null; sendReplyMessage(R.id.launch_product_query, replyURL, resultDurationMS); } From 6a41126e03dc77cd64564bdbaba4d9b288306bba Mon Sep 17 00:00:00 2001 From: Sean Owen Date: Fri, 30 Jan 2015 20:36:20 +0000 Subject: [PATCH 5/9] Proguard 5.2 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index f9819c0a6..aa9d8d64e 100644 --- a/pom.xml +++ b/pom.xml @@ -367,7 +367,7 @@ net.sf.proguard proguard-base - 5.0 + 5.2 From ef74bb6a2c1597c5e848d67d05892e7ada946f2b Mon Sep 17 00:00:00 2001 From: fakhri626 Date: Sun, 1 Feb 2015 20:15:02 +0700 Subject: [PATCH 6/9] Update strings.xml --- android/res/values-id/strings.xml | 44 +++++++++++++++---------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/android/res/values-id/strings.xml b/android/res/values-id/strings.xml index 5452b3fa4..f9d9f4a83 100644 --- a/android/res/values-id/strings.xml +++ b/android/res/values-id/strings.xml @@ -23,8 +23,8 @@ Cari Buku Batal Pencarian kustom - Panggil nomor - Kirim surel + Menghubungi nomor + Kirim email Dapatkan petunjuk arah Kirim MMS OK @@ -33,7 +33,7 @@ Cari isi Aplikasi Bookmark - Bagikan melalui surel + Bagikan melalui email Bagikan melalui SMS Clipboard Kontak @@ -42,7 +42,7 @@ Pencarian web Hubungkan ke Jaringan Informasi kontak - Alamat surel + Alamat email Koordinat geografis Nomor telepon Alamat SMS @@ -51,7 +51,7 @@ Hapus riwayat Riwayat Barcode Scanner Kosong - Tidak ada scan barcode telah dicatat belum + Tidak ada pemindaian barcode yang pernah dicatat Kirim riwayat Riwayat Gunakan MECARD @@ -61,8 +61,8 @@ Pengaturan Bagikan Bulk mode: barcode sudah dipindai dan disimpan - Maaf, kamera pada Android mengalami masalah. Anda mungkin perlu me-restart perangkat. - Bentuk + Maaf, kamera mengalami masalah. Anda mungkin perlu me-restart perangkat. + Format Metadata Hai Letakkan barcode di dalam kotak jendela untuk memindai. @@ -100,42 +100,42 @@ Data Matriks PDF417 (β) QR Codes - Perangkat Bug Workarounds - Tidak ada modus barcode scene - Gunakan hanya modus fokus standar - Tidak ada fokus terus menerus - Eksposur ada - Metering ada + Device Bug Workarounds + Tidak ada modus tempat kejadian barcode + Hanya gunakan mode fokus standar + Jangan gunakan fokus terus menerus + Tanpa eksposur + Tanpa pengukuran Otomatis Non-aktif Aktif - Meningkatkan scanning dalam cahaya rendah pada beberapa ponsel, namun dapat menyebabkan silau. Tidak bekerja pada semua ponsel. + Meningkatkan pemindaian dalam cahaya rendah pada beberapa ponsel, namun dapat menyebabkan silau. Tidak dapat bekerja pada semua ponsel. Gunakan lampu depan Pengaturan umum - Simpan scan Anda dalam Sejarah - Tambahkan ke Sejarah + Simpan hasil pemindaian Anda dalam riwayat + Tambahkan ke riwayat Memindai barcode putih pada latar belakang hitam. Tidak tersedia pada beberapa perangkat. - Balikkan memindai + Membalikkan pemindaian Pengaturan - Tidak ada rotasi otomatis - Beep + Jangan rotasi otomatis + Bunyi Simpan beberapa pindaian dari barcode yang sama di dalam Riwayat Ingat duplikasi Hasil pengaturan Ketika memindai barcode, decode\u2026 - Pencarian negara + Pilih negara Mencoba mendapatkan beberapa informasi mengenai isi barcode Ambil informasi lebih lanjut Bergetar Informasi kontak ditemukan Kalendar acara ditemukan - Alamat surel ditemukan + Alamat email ditemukan Koordinat geografis ditemukan Buku ditemukan Produk ditemukan Alamat SMS ditemukan Nomor telepon ditemukan - Teks biasa ditemukan + Teks ditemukan URL ditemukan Konfigurasi WLAN ditemukan Pencarian Google Book From 4c4b782ad9e43560d434329d890cbae3760b0a71 Mon Sep 17 00:00:00 2001 From: Sean Owen Date: Sun, 1 Feb 2015 19:48:28 +0000 Subject: [PATCH 7/9] Credit fakhri626 for Indonesian update --- AUTHORS | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS b/AUTHORS index ec208146c..8321b16db 100644 --- a/AUTHORS +++ b/AUTHORS @@ -38,6 +38,7 @@ Eric Kobrin (Velocitude) evansepdx Erik Barbara Facundo Farias +fakhri626 fics.danmark Francois B. (Google) Frank Yellin From 4b02337709279561745d7ae2ef7ff2e9f3b1a1a6 Mon Sep 17 00:00:00 2001 From: Sean Owen Date: Wed, 4 Feb 2015 07:45:35 -0600 Subject: [PATCH 8/9] Issue #300 : simplify X12 encodation at end of input stream to fix unlatch issue. HT micjahn --- .../zxing/datamatrix/encoder/X12Encoder.java | 13 ++++--------- .../encoder/HighLevelEncodeTestCase.java | 15 +++++++++++---- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/core/src/main/java/com/google/zxing/datamatrix/encoder/X12Encoder.java b/core/src/main/java/com/google/zxing/datamatrix/encoder/X12Encoder.java index fca29f250..1f88b3fa7 100644 --- a/core/src/main/java/com/google/zxing/datamatrix/encoder/X12Encoder.java +++ b/core/src/main/java/com/google/zxing/datamatrix/encoder/X12Encoder.java @@ -72,16 +72,11 @@ final class X12Encoder extends C40Encoder { context.updateSymbolInfo(); int available = context.getSymbolInfo().getDataCapacity() - context.getCodewordCount(); int count = buffer.length(); - if (count == 2) { + context.pos -= count; + if (context.getRemainingCharacters() != 1 || available != 1) { context.writeCodeword(HighLevelEncoder.X12_UNLATCH); - context.pos -= 2; - context.signalEncoderChange(HighLevelEncoder.ASCII_ENCODATION); - } else if (count == 1) { - context.pos--; - if (available > 1) { - context.writeCodeword(HighLevelEncoder.X12_UNLATCH); - } - //NOP - No unlatch necessary + } + if (count > 0) { context.signalEncoderChange(HighLevelEncoder.ASCII_ENCODATION); } } diff --git a/core/src/test/java/com/google/zxing/datamatrix/encoder/HighLevelEncodeTestCase.java b/core/src/test/java/com/google/zxing/datamatrix/encoder/HighLevelEncodeTestCase.java index 1394c8963..e4710c13d 100644 --- a/core/src/test/java/com/google/zxing/datamatrix/encoder/HighLevelEncodeTestCase.java +++ b/core/src/test/java/com/google/zxing/datamatrix/encoder/HighLevelEncodeTestCase.java @@ -16,8 +16,11 @@ package com.google.zxing.datamatrix.encoder; +import java.nio.charset.StandardCharsets; + import junit.framework.ComparisonFailure; import org.junit.Assert; +import org.junit.Ignore; import org.junit.Test; /** @@ -316,6 +319,12 @@ public final class HighLevelEncodeTestCase extends Assert { assertEquals("240 13 33 88 181 64 78 124 59 105 105 105", visualized); } + @Test + public void testX12Unlatch() { + String visualized = encodeHighLevel("*DTCP01"); + assertEquals("238 9 10 104 141 254 50 129", visualized); + } + @Test public void testBug3048549() { //There was an IllegalArgumentException for an illegal character here because @@ -334,14 +343,13 @@ public final class HighLevelEncodeTestCase extends Assert { assertEquals("236 185 185 29 196 196 129 56", visualized); } - // Not passing? - /* + @Ignore @Test public void testDataURL() { byte[] data = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x7E, 0x7F, (byte) 0x80, (byte) 0x81, (byte) 0x82}; - String expected = encodeHighLevel(new String(data, StandardCharsets.ISO-8859-1))); + String expected = encodeHighLevel(new String(data, StandardCharsets.ISO_8859_1)); String visualized = encodeHighLevel("url(data:text/plain;charset=iso-8859-1," + "%00%01%02%03%04%05%06%07%08%09%0A%7E%7F%80%81%82)"); assertEquals(expected, visualized); @@ -350,7 +358,6 @@ public final class HighLevelEncodeTestCase extends Assert { visualized = encodeHighLevel("url(data:;base64,flRlc3R+)"); assertEquals("127 85 102 116 117 127 129 56", visualized); } - */ private static String encodeHighLevel(String msg) { CharSequence encoded = HighLevelEncoder.encodeHighLevel(msg); From 625d9b77d75260495df50a383aecf95dc88cb7c2 Mon Sep 17 00:00:00 2001 From: Sean Owen Date: Fri, 6 Feb 2015 21:39:28 +0000 Subject: [PATCH 9/9] Additional fix for issue #300 (HT micjahn) --- .../com/google/zxing/datamatrix/encoder/X12Encoder.java | 5 +++-- .../zxing/datamatrix/encoder/HighLevelEncodeTestCase.java | 6 ++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/com/google/zxing/datamatrix/encoder/X12Encoder.java b/core/src/main/java/com/google/zxing/datamatrix/encoder/X12Encoder.java index 1f88b3fa7..0184bec49 100644 --- a/core/src/main/java/com/google/zxing/datamatrix/encoder/X12Encoder.java +++ b/core/src/main/java/com/google/zxing/datamatrix/encoder/X12Encoder.java @@ -73,10 +73,11 @@ final class X12Encoder extends C40Encoder { int available = context.getSymbolInfo().getDataCapacity() - context.getCodewordCount(); int count = buffer.length(); context.pos -= count; - if (context.getRemainingCharacters() != 1 || available != 1) { + if (context.getRemainingCharacters() > 1 || available > 1 || + context.getRemainingCharacters() != available) { context.writeCodeword(HighLevelEncoder.X12_UNLATCH); } - if (count > 0) { + if (context.getNewEncoding() < 0) { context.signalEncoderChange(HighLevelEncoder.ASCII_ENCODATION); } } diff --git a/core/src/test/java/com/google/zxing/datamatrix/encoder/HighLevelEncodeTestCase.java b/core/src/test/java/com/google/zxing/datamatrix/encoder/HighLevelEncodeTestCase.java index e4710c13d..15235ff1b 100644 --- a/core/src/test/java/com/google/zxing/datamatrix/encoder/HighLevelEncodeTestCase.java +++ b/core/src/test/java/com/google/zxing/datamatrix/encoder/HighLevelEncodeTestCase.java @@ -325,6 +325,12 @@ public final class HighLevelEncodeTestCase extends Assert { assertEquals("238 9 10 104 141 254 50 129", visualized); } + @Test + public void testX12Unlatch2() { + String visualized = encodeHighLevel("*DTCP0"); + assertEquals("238 9 10 104 141", visualized); + } + @Test public void testBug3048549() { //There was an IllegalArgumentException for an illegal character here because