MaxSem has uploaded a new change for review. https://gerrit.wikimedia.org/r/292295
Change subject: Wrap JSON erros in a clarifyng message ...................................................................... Wrap JSON erros in a clarifyng message Bug: T129924 Change-Id: I53437944a3874e37aa1383226c2daec958693d90 --- M i18n/en.json M i18n/qqq.json M i18n/ru.json M includes/SimpleStyleParser.php M tests/parserTests.txt 5 files changed, 17 insertions(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Kartographer refs/changes/95/292295/1 diff --git a/i18n/en.json b/i18n/en.json index e777083..a85022c 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -20,6 +20,7 @@ "kartographer-desc": "Allows maps to be added to the wiki pages", "kartographer-error-context": "<$1>: $2", "kartographer-error-context-multi": "<$1> problems:\n$2", + "kartographer-error-json": "Couldn't parse JSON: $1", "kartographer-error-missing-attr": "Attribute \"$1\" is missing", "kartographer-error-bad_attr": "Attribute \"$1\" has an invalid value", "kartographer-error-bad_data": "The JSON content is not valid GeoJSON+simplestyle", diff --git a/i18n/qqq.json b/i18n/qqq.json index e5f70ed..b40c092 100644 --- a/i18n/qqq.json +++ b/i18n/qqq.json @@ -23,6 +23,7 @@ "kartographer-desc": "{{desc|name=Kartographer|url=https://www.mediawiki.org/wiki/Extension:Kartographer}}", "kartographer-error-context": "{{Optional}}\nGeneral message shown before a single specific error\n\nParameters:\n* $1 - tag name, 'mapframe' or 'maplink'\n* $2 - error message", "kartographer-error-context-multi": "General message shown before multiple errors\n\nParameters:\n* $1 - tag name, 'mapframe', 'maplink' or 'mapdata'\n* $2 - list of errors combined into a bullet list", + "kartographer-error-json": "Error message preceding JSON errors\nParameters: $1 - underlying message from JSON parser", "kartographer-error-missing-attr": "Error shown instead of a map when required parameter(s) is missing.\n\nParameters:\n* $1 - non-localized attribute name, such as 'height', 'latitude', etc", "kartographer-error-bad_attr": "Error shown instead of a map in case of a problem with parameters.\n\nParameters:\n* $1 - non-localized attribute name, such as 'height', 'latitude', etc", "kartographer-error-bad_data": "This error is shown if the content of the tag is syntactically valid JSON however it does not adhere to GeoJSON and simplestyle specifications", diff --git a/i18n/ru.json b/i18n/ru.json index ca35f69..980bdf4 100644 --- a/i18n/ru.json +++ b/i18n/ru.json @@ -10,6 +10,7 @@ "kartographer-broken-category-desc": "Эта страница содержит недопустимое использование карты", "kartographer-desc": "Позволяет добавлять на вики-страницы карты.", "kartographer-error-context-multi": "Проблемы с <$1>:\n$2", + "kartographer-error-json": "Ошибка JSON: $1", "kartographer-error-missing-attr": "Отсутствует атрибут «$1»", "kartographer-error-bad_attr": "Атрибут «$1» имеет недопустимое значение", "kartographer-error-bad_data": "JSON содержит ошибки", diff --git a/includes/SimpleStyleParser.php b/includes/SimpleStyleParser.php index ff0917f..5acca96 100644 --- a/includes/SimpleStyleParser.php +++ b/includes/SimpleStyleParser.php @@ -59,6 +59,8 @@ $this->sanitize( $json ); $status = Status::newGood( $json ); } + } else { + $status = Status::newFatal( 'kartographer-error-json', $status->getMessage() ); } } diff --git a/tests/parserTests.txt b/tests/parserTests.txt index 039e4df..c84a066 100644 --- a/tests/parserTests.txt +++ b/tests/parserTests.txt @@ -130,7 +130,7 @@ !! result <div class="mw-kartographer mw-kartographer-error"><p><maplink> problems: </p> -<ul><li> Syntax error</li> +<ul><li> Couldn't parse JSON: Syntax error</li> <li> Attribute "longitude" has an invalid value</li> <li> Attribute "zoom" is missing</li></ul> </div> @@ -153,6 +153,17 @@ !! end !! test +Error messages - localized +!! options +language=ru +!! input +<maplink zoom=0 latitude=0 longitude=0>fail</maplink> +!! result +<div class="mw-kartographer mw-kartographer-error"><maplink>: Ошибка JSON: Синтаксическая ошибка</div> + +!! end + +!! test CSS sanitization !! input <maplink latitude=10 longitude=20 zoom=10 style="color: red;" text="<span style='color: red;'>foo</span>"/> -- To view, visit https://gerrit.wikimedia.org/r/292295 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I53437944a3874e37aa1383226c2daec958693d90 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Kartographer Gerrit-Branch: master Gerrit-Owner: MaxSem <maxsem.w...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits