Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Jennifer Killingsworth 189 posts 245 karma points
    Feb 08, 2012 @ 17:00
    Jennifer Killingsworth
    0

    4.7.1.1 - spell check in RTE

    One of our users reported that the spell check function in the Rich Text Editor isn't working.

  • Rodion Novoselov 694 posts 859 karma points
    Feb 08, 2012 @ 22:54
    Rodion Novoselov
    0

    Hi. It could be just temporary fault - Umbraco RTE actually has no own spellchecker and relies on the Google spellchecking service (so that as the latter is unavailable the RTE spellchecker doesn't work as well).

  • Jennifer Killingsworth 189 posts 245 karma points
    Feb 10, 2012 @ 15:08
    Jennifer Killingsworth
    0

    It's returning this:

    Error response:
    Index and length must refer to a location within the string.
    Parameter name: length

    Server Error in '/' Application.


    Index and length must refer to a location within the string.
    Parameter name: length

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.ArgumentOutOfRangeException: Index and length must refer to a location within the string.
    Parameter name: length

    Source Error:

    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.


    Stack Trace:

     [ArgumentOutOfRangeException: Index and length must refer to a location within the string. Parameter name: length] System.String.InternalSubStringWithChecks(Int32 startIndex, Int32 length, Boolean fAlwaysCopy) +12681861 umbraco.presentation.umbraco_client.tinymce3.plugins.spellchecker.GoogleSpellChecker.CheckWords(String language, String[] words) +469 umbraco.presentation.umbraco_client.tinymce3.plugins.spellchecker.GoogleSpellChecker.ProcessRequest(HttpContext context) +247 System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +625 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +270 



    Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.272

  • Tom Fulton 2030 posts 4984 karma points c-trib
    Feb 10, 2012 @ 15:12
    Tom Fulton
    0

    Hi Jennifer,

    IIRC there is a bug if you have single quotes (') in your content.  I think it's an issue with javascript not escaping them properly when sending your content to google.  Here is the bug report:  http://umbraco.codeplex.com/workitem/30215

    Probably wouldn't be that hard to fix, maybe if I get some time I'll take a stab :)

    -Tom

  • Mark 49 posts 130 karma points
    May 08, 2012 @ 05:11
    Mark
    0

    Had to fix this for a client, believe the problem is that the data sent to google for spellchecking is urlencoded, but when processing the result the data isn't so is a differing length, so just re-encoded the data before performing the substring, seems to work fine.

    Beware this is just a quick fix and not extensively tested.

    modify - /config/tinyMceConfig.config

    <config key="spellchecker_rpc_url">GSpellChecker.ashx</config>

    create - /umbraco/GSpellChecker.ashx

    public class GSpellChecker : SpellChecker, IHttpHandler {
      // Methods
      public override SpellCheckerResult CheckWords(string language, string[] words) {
        XmlDocument document = new XmlDocument();
        string data = string.Join(" ", words);
        string xml = SendRequest(language, data);
        document.LoadXml(xml);
        data = HttpContext.Current.Server.UrlEncode(data);
        SpellCheckerResult result = new SpellCheckerResult();
        foreach (XmlNode node in document.SelectNodes("//c")) {
          XmlElement element = (XmlElement)node;
          result.result.Add(data.Substring(Convert.ToInt32(element.GetAttribute("o")), Convert.ToInt32(element.GetAttribute("l"))));
        }
        return result;
      }
    
      public override SpellCheckerResult GetSuggestions(string language, string word) {
        XmlDocument document = new XmlDocument();
        string xml = SendRequest(language, word);
        document.LoadXml(xml);
        SpellCheckerResult result = new SpellCheckerResult();
        foreach (XmlNode node in document.SelectNodes("//c")) {
          XmlElement element = (XmlElement)node;
          foreach (string str2 in element.InnerText.Split(new char[] { '\t' })) {
            if (!string.IsNullOrEmpty(str2)) {
              result.result.Add(str2);
            }
          }
        }
        return result;
      }
    
      public void ProcessRequest(HttpContext context) {
        SpellCheckerInput input = SpellCheckerInput.Parse(new StreamReader(context.Request.InputStream));
        SpellCheckerResult suggestions = null;
        string method = input.Method;
        if (method != null) {
          if (!(method == "checkWords")) {
            if (method == "getSuggestions") {
              suggestions = this.GetSuggestions(input.Language, input.Words[0]);
              goto Label_007C;
            }
          } else {
            suggestions = this.CheckWords(input.Language, input.Words.ToArray());
            goto Label_007C;
          }
        }
        suggestions = new SpellCheckerResult();
      Label_007C:
        suggestions.id = input.Id;
        string s = new JavaScriptSerializer().Serialize(suggestions);
        context.Response.Write(s);
      }
    
      private static string SendRequest(string lang, string data) {
        string str;
        string requestUriString = string.Format("https://www.google.com:443/tbproxy/spell?lang={0}&hl={0}", lang);
        string s = string.Format("<?xml version=\"1.0\" encoding=\"utf-8\" ?><spellrequest textalreadyclipped=\"0\" ignoredups=\"0\" ignoredigits=\"1\" ignoreallcaps=\"1\"><text>{0}</text></spellrequest>", HttpContext.Current.Server.UrlEncode(data));
        StreamReader reader = null;
        HttpWebResponse response = null;
        Stream requestStream = null;
        try {
          HttpWebRequest request = (HttpWebRequest)WebRequest.Create(requestUriString);
          request.KeepAlive = false;
          request.Method = "POST";
          request.ContentType = "application/PTI26";
          request.ContentLength = s.Length;
          WebHeaderCollection headers = request.Headers;
          headers.Add("MIME-Version: 1.0");
          headers.Add("Request-number: 1");
          headers.Add("Document-type: Request");
          headers.Add("Interface-Version: Test 1.4");
          requestStream = request.GetRequestStream();
          byte[] bytes = new ASCIIEncoding().GetBytes(s);
          requestStream.Write(bytes, 0, bytes.Length);
          response = (HttpWebResponse)request.GetResponse();
          reader = new StreamReader(response.GetResponseStream());
          str = reader.ReadToEnd();
        } finally {
          if (requestStream != null) {
            requestStream.Close();
          }
          if (reader != null) {
            reader.Close();
          }
          if (response != null) {
            response.Close();
          }
        }
        return str;
      }
    
      // Properties
      public bool IsReusable {
        get {
          return false;
        }
      }
    }
  • Arturo Soler 24 posts 77 karma points
    Mar 05, 2013 @ 14:03
    Arturo Soler
    0

    Thanks Mark, just that to help other dummies (like me): it requires the following "using"s

    using System;
    using System.Web;
    using umbraco.presentation.umbraco_client.tinymce3.plugins.spellchecker;
    using System.Xml;
    using System.IO;
    using System.Web.Script.Serialization;
    using System.Net;
    using System.Text;
  • Adrian Holland 29 posts 106 karma points
    Jul 31, 2013 @ 03:20
    Adrian Holland
    0

    The Google spellchecker service this relies on (https://www.google.com/tbproxy/spellmay have been turned off for good.

     

    An alternative is the HunSpellChecker plugin

Please Sign in or register to post replies

Write your reply to:

Draft