журнал (shhh) wrote in changelog,
журнал
shhh
changelog

[livejournal] r23427: LJSUP-14487: XML-RPC: WP7 bug with frien...

Committer: nnikulochkina
LJSUP-14487: XML-RPC: WP7 bug with friendsfeed
U   trunk/cgi-bin/LJ/Entry.pm
U   trunk/cgi-bin/ljprotocol.pl
Modified: trunk/cgi-bin/LJ/Entry.pm
===================================================================
--- trunk/cgi-bin/LJ/Entry.pm	2012-12-06 09:45:23 UTC (rev 23426)
+++ trunk/cgi-bin/LJ/Entry.pm	2012-12-06 10:15:08 UTC (rev 23427)
@@ -556,7 +556,29 @@
     return 1;
 }
 
+sub normalize_props {
+    my $self = shift;
 
+    return unless $self->{_loaded_props};
+
+    foreach my $pname ( keys %{$self->{props}} ) {
+        my $pval  = $self->{props}{$pname};
+        
+        next unless defined $pval;
+
+        my $prop  = LJ::get_prop("log", $pname);
+        my $ptype = $prop->{'datatype'};
+        
+        if ($ptype eq "bool" && $pval !~ /^[01]$/) {
+            $self->{props}{$pname} = $pval ? 1 : 0;
+        } 
+
+        if ($ptype eq "num" && $pval =~ /[^\d]/) {
+            $self->{props}{$pname} = int $pval;
+        }
+    }
+}
+
 # called automatically on $event->comments
 # returns the same data as LJ::get_talk_data, with the addition
 # of 'subject' and 'event' keys.

Modified: trunk/cgi-bin/ljprotocol.pl
===================================================================
--- trunk/cgi-bin/ljprotocol.pl	2012-12-06 09:45:23 UTC (rev 23426)
+++ trunk/cgi-bin/ljprotocol.pl	2012-12-06 10:15:08 UTC (rev 23427)
@@ -1338,6 +1338,8 @@
             $entry = $original_entry;
         }
 
+        $entry->normalize_props() unless $flags->{'noauth'};
+
         # Add more data for public posts
         foreach my $method (@attrs) {
             $h{$method} = $entry->$method;
@@ -4447,8 +4449,23 @@
             $evt->{'props'} = {};
 
             foreach my $name (keys %{$props{$itemid}}) {
+
                 my $value = $props{$itemid}->{$name};
                 $value =~ s/\n/ /g;
+
+                # normalize props
+                unless ($flags->{'noauth'}) {
+                    my $prop  = LJ::get_prop("log", $name);
+                    my $ptype = $prop->{'datatype'};
+                
+                    if ($ptype eq "bool" && $value !~ /^[01]$/) {
+                        $value = $value ? 1 : 0;
+                    }
+                    if ($ptype eq "num" && $value =~ /[^\d]/) {
+                        $value = int $value;
+                    }
+                }
+
                 $evt->{'props'}->{$name} = $value;
             }
 

Tags: livejournal, nikulochkina, nnikulochkina, pl, pm
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments