Commit 9f037d2a authored by Mygod's avatar Mygod

Forbid usage of control characters in PluginOptions

parent 0bac32b7
...@@ -149,7 +149,7 @@ class ProfileConfigFragment : PreferenceFragmentCompat(), ...@@ -149,7 +149,7 @@ class ProfileConfigFragment : PreferenceFragmentCompat(),
DataStore.plugin = pluginConfiguration.toString() DataStore.plugin = pluginConfiguration.toString()
DataStore.dirty = true DataStore.dirty = true
true true
} catch (exc: IllegalArgumentException) { } catch (exc: RuntimeException) {
(activity as MainActivity).snackbar(exc.localizedMessage).show() (activity as MainActivity).snackbar(exc.localizedMessage).show()
false false
} }
......
...@@ -84,6 +84,7 @@ ...@@ -84,6 +84,7 @@
android:key="plugin.configure" android:key="plugin.configure"
android:icon="@drawable/ic_action_settings" android:icon="@drawable/ic_action_settings"
android:persistent="false" android:persistent="false"
android:singleLine="true"
app:pref_summaryHasText="%s" app:pref_summaryHasText="%s"
android:title="@string/plugin_configure"/> android:title="@string/plugin_configure"/>
<Preference <Preference
......
* 1.1.0: * 1.1.0:
* Having control characters in plugin options is no longer allowed.
If this breaks your plugin, you are doing it wrong.
* New helper method: `PluginOptions.putWithDefault`. * New helper method: `PluginOptions.putWithDefault`.
* 1.0.0: * 1.0.0:
* `PathProvider` now takes `Int` instead of `String` for file modes; * `PathProvider` now takes `Int` instead of `String` for file modes;
......
...@@ -38,6 +38,7 @@ class PluginOptions : HashMap<String, String?> { ...@@ -38,6 +38,7 @@ class PluginOptions : HashMap<String, String?> {
@Suppress("NAME_SHADOWING") @Suppress("NAME_SHADOWING")
var parseId = parseId var parseId = parseId
if (options.isNullOrEmpty()) return if (options.isNullOrEmpty()) return
check(options.all { !it.isISOControl() }) { "No control characters allowed." }
val tokenizer = StringTokenizer("$options;", "\\=;", true) val tokenizer = StringTokenizer("$options;", "\\=;", true)
val current = StringBuilder() val current = StringBuilder()
var key: String? = null var key: String? = null
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment