android / android/project-replicator

xml parser skips files with DOCTYPE entries

オープン
#39 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

主要言語
Kotlin
スター
136
フォーク
40
PR マージ指標
30日以内にマージされた PR はありません

説明

> Task :my-module:gatherModuleInfo
e: Invalid xml file my-module/src/main/res/values/strings.xml
   line 4; column 10: DOCTYPE is disallowed when the feature "http://apache.org/xml/features/disallow-doctype-decl" set to true.
   <!DOCTYPE resources [
            ↑
Skipping file parsing

This does not terminate the process, it just skips the file.

I'm not sure what the reason is for disallowing DOCTYPE, but it is useful to add named entities for unusual characters. For example, we use it to define entity aliases like these that we can then use in our strings:

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE resources [
    <!ENTITY ldquo  "&#8220;">
    <!ENTITY rdquo  "&#8221;">
    <!ENTITY lsquo  "&#8216;">
    <!ENTITY rsquo  "&#8217;">
    <!ENTITY hellip "&#8230;">
    <!ENTITY prime  "&#8242;">
    <!ENTITY Prime  "&#8243;">
    <!ENTITY bull   "&#8226;">
    <!ENTITY thinsp "&#8201;">
    <!ENTITY hairsp "&#8202;">
    ]>

Then later we can refer to these standard entity names in the strings:

<string name="string_name">One last thing&hellip;</string>

In this case, we prefer to use &hellip; here, because it is more meaningful for translators, and it is more grammatically correct. I.e., using vs .... It also translates differently for some languages - for example, some languages prefer a different type of ellipsis, like the midline () or vertical ellipsis ().

Inlining the unicode character can often be difficult for people reading the file to understand that it is a unicode character rather than its similar non-unicode counterpart (i.e., ' apostrophe vs right-single quotation or rsquo), which is why we use the &#<>; notation. And inlining that notation into the string, someone reading the file won't understand what that number represents unless they look it up.

So the workaround is using the named XML entity: it gives us the exact unicode representation, with a meaningful name, without compromising the character width which can have an impact on some older editors that aren't well equipped to handle multi-byte unicode characters.

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

:my-module:gatherModuleInfo タスクの背後にあるコードと、my-module/src/main/res/values/strings.xml の解析から始めてください。XML パーサーが報告された DOCTYPE をどのように処理するかを確認し、… のような名前付きエンティティのカバレッジを追加してください。ファイルがスキップされずに解析され、名前付きエンティティが strings で引き続き使用できれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
android, kotlin
領域
build-system
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。