mirror of
https://github.com/zxing/zxing.git
synced 2025-02-02 05:41:08 -08:00
Decode HTML entities in titles
This allows page titles with HTML entities like `&` to display properly. Before, no decoding would be performed and `&` would be shown where an ampersand should be. Additionally, decoding entities prevents the following string length check from overcounting. To replicate this bug scan an image with a URL pointing to http://stackoverflow.com/questions/tagged/android The title displayed within the app will be something like: `Frequent 'android' Questions - Stack Overflow` After this commit, the app will display the correct decoded title: `Frequent 'android' Questions - Stack Overflow`
This commit is contained in:
parent
faee672889
commit
955a9e8a8d
|
@ -16,6 +16,7 @@
|
|||
|
||||
package com.google.zxing.client.android.result.supplement;
|
||||
|
||||
import android.text.Html;
|
||||
import android.widget.TextView;
|
||||
import com.google.zxing.client.android.HttpHelper;
|
||||
import com.google.zxing.client.android.history.HistoryManager;
|
||||
|
@ -56,6 +57,7 @@ final class TitleRetriever extends SupplementalInfoRetriever {
|
|||
if (m.find()) {
|
||||
String title = m.group(1);
|
||||
if (title != null && !title.isEmpty()) {
|
||||
title = Html.fromHtml(title).toString();
|
||||
if (title.length() > MAX_TITLE_LEN) {
|
||||
title = title.substring(0, MAX_TITLE_LEN) + "...";
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue