<commit_before>using System;
using System.Reflection;
using System.Collections.Generic;

using Monodoc;

using Qyoto;
using Kimono;

public class MySlave : KIO.SlaveBase {
	public MySlave(QByteArray protocol, QByteArray pool_sock, QByteArray app_sock)
		: base(protocol, pool_sock, app_sock)
	{
	}

	public static RootTree HelpTree = RootTree.LoadTree();

	public static string GetHtml(string url, Node n, out Node match) {
		match = null;
		if (url.StartsWith("edit:")) return null;
		
		string html = null;
		
		if (n != null && n.tree.HelpSource != null) {
			try {
				html = n.tree.HelpSource.GetText(url, out match);
			} catch {
				bool showInherited = SettingsHandler.Settings.ShowInheritedMembers;
				SettingsHandler.Settings.ShowInheritedMembers = false;
				html = n.tree.HelpSource.GetText(url, out match);
				SettingsHandler.Settings.ShowInheritedMembers = showInherited;
			}
		}
		
		if (html == null || html == "") {
			try {
				html = HelpTree.RenderUrl(url, out match);
			} catch {
				bool showInherited = SettingsHandler.Settings.ShowInheritedMembers;
				SettingsHandler.Settings.ShowInheritedMembers = false;
				html = HelpTree.RenderUrl(url, out match);
				SettingsHandler.Settings.ShowInheritedMembers = showInherited;
			}
		}
		
		return html;
	}

	public override void Get(KUrl url) {
		string docurl = url.ToString().Substring(9);
		if (docurl == string.Empty) {
			Redirection(new KUrl("monodoc:/root:/classlib"));
			Finished();
			return;
		}
		MimeType("application/xhtml+xml");
		Node n;
		try {
			string data = GetHtml(docurl, null, out n);
			data = data.Replace("href=\"", "href=\"monodoc:/");
			Data(data);
		} catch {
			Data("The requested url is not availible");
		}
		Finished();
	}
}<commit_msg>* Fix kio_monodoc crashing on an invalid URL.<commit_after>using System;
using System.Reflection;
using System.Collections.Generic;

using Monodoc;

using Qyoto;
using Kimono;

public class MySlave : KIO.SlaveBase {
	public MySlave(QByteArray protocol, QByteArray pool_sock, QByteArray app_sock)
		: base(protocol, pool_sock, app_sock)
	{
	}

	public static RootTree HelpTree = RootTree.LoadTree();

	public static string GetHtml(string url, Node n, out Node match) {
		match = null;
		if (url.StartsWith("edit:")) return null;
		
		string html = null;
		
		if (n != null && n.tree.HelpSource != null) {
			try {
				html = n.tree.HelpSource.GetText(url, out match);
			} catch {
				bool showInherited = SettingsHandler.Settings.ShowInheritedMembers;
				SettingsHandler.Settings.ShowInheritedMembers = false;
				html = n.tree.HelpSource.GetText(url, out match);
				SettingsHandler.Settings.ShowInheritedMembers = showInherited;
			}
		}
		
		if (html == null || html == "") {
			try {
				html = HelpTree.RenderUrl(url, out match);
			} catch {
				bool showInherited = SettingsHandler.Settings.ShowInheritedMembers;
				SettingsHandler.Settings.ShowInheritedMembers = false;
				html = HelpTree.RenderUrl(url, out match);
				SettingsHandler.Settings.ShowInheritedMembers = showInherited;
			}
		}
		
		return html;
	}

	public override void Get(KUrl url) {
		string docurl = url.ToString().Substring(9);
		if (docurl == string.Empty) {
			Redirection(new KUrl("monodoc:/root:/classlib"));
			Finished();
			return;
		}
		MimeType("application/xhtml+xml");
		Node n;
		try {
			string data = GetHtml(docurl, null, out n);
			if (data != null) {
				data = data.Replace("href=\"", "href=\"monodoc:/");
				Data(data);
			} else {
				Data("The requested url is not availible");
			}
		} catch {
			Data("The requested url is not availible");
		}
		Finished();
	}
}
{'fraction_non_alphanumeric': 0.12423907028223576, 'fraction_numerical': 0.0005534034311012728, 'mean_word_length': 3.7378768020969857, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3098592', 'n_tokens_mistral': 1381, 'n_tokens_neox': 1180, 'n_words': 281}