Backslash-apostrophe POOF.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Razzbar

    Backslash-apostrophe POOF.

    I'm working on a bookmarklet that grabs information from a page and
    submits it to a server. Yet another social bookmarking application.
    I'm having trouble with page titles that include an apostrophe.

    I'm using encodeURICompon ent() around the page title, and again around
    the URL. Apparently the browser is inserting a backslash before any
    apostrophe. I can see that when I write the $_GET data to a file in
    PHP on the server. When the GET data is processed, PHP generates a
    page with a form, and the data is plugged into some input fields. The
    page is sent to the user's browser for editing and approval, and
    there's where the problem shows up. Here's the transformation. ..

    Say we have a page with the title "Here's the page" (minus the
    outer quotes)

    Page title: -- Here's the page // the title gets
    encodeURICompon ent
    PHP gets -- Here\'s the page // a backslash gets
    inserted somehow.
    HTML form -- Here\ // truncated!

    I don't know why this is happening, or what to do about it. I tried
    using PHP stripslashes() and that doesn't do it. What do I need to
    do?
  • Olaf Schinkel

    #2
    Re: Backslash-apostrophe POOF.

    Hi!

    Razzbar schrieb:
    I'm working on a bookmarklet that grabs information from a page and
    submits it to a server. Yet another social bookmarking application.
    I'm having trouble with page titles that include an apostrophe.
    >
    I'm using encodeURICompon ent() around the page title, and again around
    the URL. Apparently the browser is inserting a backslash before any
    apostrophe. I can see that when I write the $_GET data to a file in
    PHP on the server. When the GET data is processed, PHP generates a
    page with a form, and the data is plugged into some input fields. The
    page is sent to the user's browser for editing and approval, and
    there's where the problem shows up. Here's the transformation. ..
    >
    Say we have a page with the title "Here's the page" (minus the
    outer quotes)
    >
    Page title: -- Here's the page // the title gets
    encodeURICompon ent
    PHP gets -- Here\'s the page // a backslash gets
    inserted somehow.
    HTML form -- Here\ // truncated!
    >
    I don't know why this is happening, or what to do about it. I tried
    using PHP stripslashes() and that doesn't do it. What do I need to
    do?
    Are maybe there *two* times \\?
    So encodeURICompon ent make that: Here\'s
    And magic qutoes makes that: Here\\\'

    I use this construct:
    $bd = urlencode($_REQ UEST['m_body']);
    $bd = get_magic_quote s_gpc() ? $bd : urlencode($bd);

    Comment

    • Jerry Stuckle

      #3
      Re: Backslash-apostrophe POOF.

      Razzbar wrote:
      I'm working on a bookmarklet that grabs information from a page and
      submits it to a server. Yet another social bookmarking application.
      I'm having trouble with page titles that include an apostrophe.
      >
      I'm using encodeURICompon ent() around the page title, and again around
      the URL. Apparently the browser is inserting a backslash before any
      apostrophe. I can see that when I write the $_GET data to a file in
      PHP on the server. When the GET data is processed, PHP generates a
      page with a form, and the data is plugged into some input fields. The
      page is sent to the user's browser for editing and approval, and
      there's where the problem shows up. Here's the transformation. ..
      >
      Say we have a page with the title "Here's the page" (minus the
      outer quotes)
      >
      Page title: -- Here's the page // the title gets
      encodeURICompon ent
      PHP gets -- Here\'s the page // a backslash gets
      inserted somehow.
      HTML form -- Here\ // truncated!
      >
      I don't know why this is happening, or what to do about it. I tried
      using PHP stripslashes() and that doesn't do it. What do I need to
      do?
      >
      What do you see when you look at the page source?

      --
      =============== ===
      Remove the "x" from my email address
      Jerry Stuckle
      JDS Computer Training Corp.
      jstucklex@attgl obal.net
      =============== ===

      Comment

      • Geoff Berrow

        #4
        Re: Backslash-apostrophe POOF.

        Message-ID:
        <b78e24b4-221d-487e-8226-cf9a9c778300@i2 0g2000prf.googl egroups.comfrom
        Razzbar contained the following:
        >I don't know why this is happening, or what to do about it. I tried
        >using PHP stripslashes() and that doesn't do it. What do I need to
        >do?
        Probably...

        htmlentities(st ripslashes($var ), ENT_QUOTES);

        --
        Geoff Berrow 011000100110110 0010000000110
        001101101011011 001000110111101 100111001011
        100110001101101 111001011100111 010101101011
        The Slippery Hill Boys Tel: 07985 425932. American themed barn dances and bluegrass performances. Stoke on Trent, Newcastle under Lyme, Staffordshire, Cheshire and surrounding areas.

        Comment

        • Razzbar

          #5
          Re: Backslash-apostrophe POOF.

          On Jul 26, 9:58 am, Geoff Berrow <blthe...@ckdog .co.ukwrote:
          Probably...
          >
          htmlentities(st ripslashes($var ), ENT_QUOTES);
          >
          It's trickier than that! Simply using stripslashes() solved the
          backslash+apost rophe issue, but then I tried it on a page title with
          some HTML entities in it, and once again, there was a truncation at
          the first '<' character. So... using your code solved that one. Until
          I had a title that was in Japanese, which gave no problem until I
          started fixing this. That one renders the UTF codes, not the
          characters as before.

          Heh.

          Comment

          Working...