Results 1 to 4 of 4

Thread: url preg_replace

  1. #1
    kikko1 is offline Unknown Net Builder
    Join Date
    Nov 2010
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    url preg_replace

    Why preg_replace delete the " " in href?

    Example
    The normal link syntax is:
    HTML Code:
    <a href="/mydir/mypag.html"> </ a>
    output instead rewrites:
    HTML Code:
    <a href=mydir/mypag.html></ a>
    How can you fix this error?

  2. #2
    Mike-XS's Avatar
    Mike-XS is offline XeroAgent
    Join Date
    Sep 2009
    Location
    OZ
    Posts
    209
    Thanks
    30
    Thanked 109 Times in 71 Posts
    Hi kikko1.

    To fix your error, you'll probably need to either take out any double quotes from the pattern matching rule or possibly escape the double quotes.

    To help you better though, it would help us a lot more if we could see the PHP code you are having problems with.

  3. #3
    kikko1 is offline Unknown Net Builder
    Join Date
    Nov 2010
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Mike-XS View Post
    Hi kikko1.

    To fix your error, you'll probably need to either take out any double quotes from the pattern matching rule or possibly escape the double quotes.

    To help you better though, it would help us a lot more if we could see the PHP code you are having problems with.
    Hi Mike-XS
    thank you for the reply.

    Sorry, but the code php is translation script.

    In short, the translation script calls the page to be translated, rewrites the translated page into the cache, but the output code does not adds the double quoted on all the tag <a href=.

    I do not know which file generates the error:

    • index.php
    • translate.php
    • tr_fixup.php


  4. #4
    kikko1 is offline Unknown Net Builder
    Join Date
    Nov 2010
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Ok.
    This is the function that eliminates the url translate.google.
    The file is:
    tr_google.php
    PHP Code:
    function GoogleFixupTagLinks($content)
    {
     
    //echo "GoogleFixupTagLinks called with: $content\n";
    //FIXME: matching spaces may break things, but google is sending unquoted tag attributes...
        
    $rstr '|(http://.+?/translate_.*?)([ ">])|i';       
        
    $content preg_replace_callback($rstr,'fix_link_cb',$content);
        return 
    $content;

    Sorry, I have only found out now that google is sending the tag attributes without the quotes.

    But I think you can add quotes with a php function.
    But I am not able to create it.
    Maybe I am a nob or is it just that you can not do it?


    I apologise for my bad english

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •