Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

aurget urlencode patch

By: a guest on Jun 19th, 2010  |  syntax: Diff  |  size: 1.17 KB  |  views: 117  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. 135a136,154
  2. > # url encode a string
  3. > url_encode() {
  4. >   [ $# -lt 1 ] && { return; }
  5. >
  6. >   encodedurl="$1";
  7. >
  8. >   # make sure hexdump exists, if not, just give back the url
  9. >   [ ! -x "/usr/bin/hexdump" ] && { return; }
  10. >
  11. >   encodedurl=`
  12. >     echo $encodedurl | hexdump -v -e '1/1 "%02x\t"' -e '1/1 "%_c\n"' |
  13. >     LANG=C awk '
  14. >       $1 == "20"                    { printf("%s",   "+"); next } # space becomes plus
  15. >       $1 ~  /0[adAD]/               {                      next } # strip newlines
  16. >       $2 ~  /^[a-zA-Z0-9.*()\/-]$/  { printf("%s",   $2);  next } # pass through what we can
  17. >                                     { printf("%%%s", $1)        } # take hex value of everything else
  18. >     '`
  19. > }
  20. >
  21. 585c604,605
  22. <     read -r Name Version URLPath < <(wget -q -O - "${aur_info}${name}" | grep -Fv -- "\"No result found\"" | sed -e 's/.*"Name":"\([^"]*\)".*"Version":"\([^"]*\)".*"URLPath":"\([^"]*\)".*/\1 \2 \3/g')
  23. ---
  24. >     url_encode "${name}"
  25. >     read -r Name Version URLPath < <(wget -q -O - "${aur_info}${encodedurl}" | grep -Fv -- "\"No result found\"" | sed -e 's/.*"Name":"\([^"]*\)".*"Version":"\([^"]*\)".*"URLPath":"\([^"]*\)".*/\1 \2 \3/g')