1

I am trying to pass this string as a get parameter. This string starts with the following characters :

string name is some_html it is basically some html

 <p style=\"-qt-block-indent: 0; text-indent: 0px; margin: 18px 0px 12px 0px;\"><span style=\"font-size: xx-large; 

However I only get this

<p style=\\"-qt-block-indent: 0

This is how I am passing the string:

http://127.0.0.1:8000/service_SubmitResult?htmlstring=some_html

Any idea on what I might be doing wrong. I am sending the string via Qt and receiving it on Django endpoint? I believe its because of the semicolon . I am using the following function for encoding the url before sending it out

QUrl ServiceCalls::UrlFromUserInput(const QString& input)
{
   QByteArray latin = input.toLatin1();
   QByteArray utf8 = input.toUtf8();
   if (latin != utf8)
   {
      // URL string containing unicode characters (no percent encoding expected)
      return QUrl::fromUserInput(input);
   }
   else
   {
      // URL string containing ASCII characters only (assume possible %-encoding)
      return QUrl::fromUserInput(QUrl::fromPercentEncoding(input.toLatin1()));
   }
}

Why am I receiving only a part of the string. On django i am getting the parameter value in the following way

def service_foo(request):
    try:
        htmlResult = request.GET.get('htmlstring', '')
        ....
        return HttpResponse();
    except Exception as e:
        print(e)
    return HttpResponse("Error Service from sqlite")

Any suggestions on how I can fix this or what other options i can use ?

Community
  • 1
  • 1
James Franco
  • 4,516
  • 10
  • 38
  • 80
  • Isn't taht just a duplicate of http://stackoverflow.com/questions/39941177/passing-a-string-containing-html-as-a-http-get-parameter-how-to-url-encode-it – Kevin Krammer Oct 09 '16 at 16:37
  • Yes it was but i deleted that question as this has more details in it – James Franco Oct 09 '16 at 16:40
  • You deleted it just now, otherwise I couldn't have linked it. Very nice of you to delete my answer like that – Kevin Krammer Oct 09 '16 at 16:45
  • @KevinKrammer I asked for an answer which explicitly took a string in and returned back a string. Your string was working with QUrl which i did not want.Would you like me to undelete it and point that out there ? Let me know what works for you – James Franco Oct 09 '16 at 16:48
  • @KevinKrammer I undeleted the answer – James Franco Oct 09 '16 at 16:50

1 Answers1

0

I think you must make string, html escaped before sending it in qt there are some ways to do it. Take a look at this issue.

Community
  • 1
  • 1